BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-05-2008, 05:23 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Error ( cannot find symbol : variable KeyCodeEvent ) when using EventInjector

Please Login to Remove!

I had used this code to terminate an Outbound Phone Call


Code:
public void callInitiated(int callid) {
        print("callInitiated");

        // To prevent simultaneous handling... If locked.. simply return
        if (locked) return;
        else locked = true;
              
        disconnectCall();
        // do your things..
        
        // release lock
        locked = false;
}



private void disconnectCall() {
            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END,
                    KeypadListener.STATUS_NOT_FROM_KEYPAD, 10);
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
                    KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END,
                    KeypadListener.STATUS_NOT_FROM_KEYPAD, 10);
            EventInjector.invokeEvent(pressEndKey);
            try {Thread.sleep(50);} catch (InterruptedException ex) {ex.printStackTrace();}
            EventInjector.invokeEvent(releaseEndKey);
}



But I am geting the following error when compiling it

Do I have to import any library ?

Building MyPhone
C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import=..\lib\net_rim_api.jar codename=MyPhone MyPhone.rapc warnkey=0x52424200;0x52435200;0x52525400 "C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPho ne.java" "C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\icon. png"
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPho ne.java:31: cannot find symbol
symbol : variable KeyCodeEvent
location: class com.blackberrydeveloper.myphone.MyPhone
EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYP AD, 10);
^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPho ne.java:31: internal error; cannot instantiate KeyCodeEvent(int,char,int,int) at net.rim.device.api.system.EventInjector.KeyCodeEve nt to ()
EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYP AD, 10);
^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPho ne.java:32: cannot find symbol
symbol : variable KeyCodeEvent
location: class com.blackberrydeveloper.myphone.MyPhone
EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYP AD, 10);
^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPho ne.java:32: internal error; cannot instantiate KeyCodeEvent(int,char,int,int) at net.rim.device.api.system.EventInjector.KeyCodeEve nt to ()
EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYP AD, 10);
^
4 errors
Error!: Error: java compiler failed: javac -source 1.3 -target 1.1 -g -O -d C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\rapc_6eb20e26.d ir -bootcl ...
Error while building project
Offline  
Old 07-08-2008, 01:47 PM   #2 (permalink)
aux
New Member
 
Join Date: May 2008
Model: 8100
PIN: N/A
Carrier: mtel
Posts: 8
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default hi!!! your problem is easy!!!

Change KeyCodeEvent.KEY_DOWN by EventInjector.KeyCodeEvent.KEY_DOWN
and KeyCodeEvent.KEY_UP by EventInjector.KeyCodeEvent.KEY_UP
Offline  
Old 07-08-2008, 01:58 PM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I would try it

Thanks very much for your help
Offline  
Old 07-08-2008, 02:57 PM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

That was helpful but I am still getting 2 errors


Code:
C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe  -quiet import="..\..\..\..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=SuperDiverter SuperDiverter.rapc warnkey=0x52424200;0x52435200;0x52525400 "C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\CallDivert\SmplCallDiverter.java" "C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\CallDivert\SuperDiverter.java" "C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\CallDivert\icon.png"
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\CallDivert\SmplCallDiverter.java:163: '(' or '[' expected
EventInjector.KeyCodeEvent pressEndKey=new EventInjector.KeyCodeEvent.KEY_DOWN,Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD,100;
                                                                              ^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\CallDivert\SmplCallDiverter.java:164: '(' or '[' expected
EventInjector.KeyCodeEvent releaseEndKey=new EventInjector.KeyCodeEvent.KEY_UP,(char)Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD,100;
                                                                              ^
2 errors
Error!: Error: java compiler failed: javac -source 1.3 -target 1.1 -g -O -d C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\rapc_03eb90fb.dir -bootcl ...
Error while building project

Can you please say what could be the problem ?
Offline  
Old 07-09-2008, 01:44 AM   #5 (permalink)
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Post Thanks: 0
Thanked 0 Times in 0 Posts
Cool

That code is wrong ...

Give it like :


new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100);
Offline  
Old 07-09-2008, 05:23 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I was using the same code earlier but it was showing me 4 errors

When I used the other code , it got reduced to 2 errors

Can you polease post the full code if possible ?
Offline  
Old 07-09-2008, 05:45 AM   #7 (permalink)
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Post Thanks: 0
Thanked 0 Times in 0 Posts
Cool

you have to import EventInjector, Keypad, KeyCodeEvent... classes to the application. Just check that...
Offline  
Old 07-09-2008, 06:00 AM   #8 (permalink)
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ctrl+shift+o in eclipse
__________________
java developer, Devinto, hamburg/germany
Offline  
Old 07-09-2008, 07:38 AM   #9 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

I had declared

import net.rim.blackberry.api.invoke.*;

It was still giving me errors
Offline  
Old 07-10-2008, 04:23 PM   #10 (permalink)
New Member
 
Join Date: Jun 2008
Model: 9550
PIN: N/A
Carrier: Rogers
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

EventInjector is part of the regular device system api, so importing the system api and then doing:

EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));

EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));

should work perfectly, as it is for me.

note: NativeConstants and Keypad constants are interchangeable
Offline  
Old 07-11-2008, 07:00 AM   #11 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Thanks very much for for your help

I wil try it soon

Can you please say what all Models does it work on ?

Does it work on Real devices or on just the Simulator ?

Quote:
Originally Posted by Quincy View Post

should work perfectly, as it is for me.

note: NativeConstants and Keypad constants are interchangeable
Offline  
Old 07-11-2008, 09:59 AM   #12 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Quincy

I got the following errors

Building QuitCall
C:\Program Files\Research In Motion\BlackBerry JDE 4.2.1\bin\rapc.exe -quiet import="..\..\..\..\..\Program Files\Research In Motion\BlackBerry JDE 4.2.1\lib\net_rim_api.jar" codename=QuitCall QuitCall.rapc warnkey=0x52424200;0x52435200;0x52525400 "C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java"
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:116 : cannot find symbol
symbol : variable NativeConstants
location: class com.blackberrydeveloper.QuitCall.QuitCall
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN,(char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:116 : inconvertible types
found : NativeConstants.KEY_SEND
required: char
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN,(char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:116 : internal error; cannot instantiate net.rim.device.api.system.EventInjector.KeyCodeEve nt.<init> at net.rim.device.api.system.EventInjector.KeyCodeEve nt to ()
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN,(char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:118 : cannot find symbol
symbol : variable NativeConstants
location: class com.blackberrydeveloper.QuitCall.QuitCall
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:118 : inconvertible types
found : NativeConstants.KEY_SEND
required: char
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
C:\Documents and Settings\Administrator\My Documents\BlkBerryProjs\QuitCall\QuitCall.java:118 : internal error; cannot instantiate net.rim.device.api.system.EventInjector.KeyCodeEve nt.<init> at net.rim.device.api.system.EventInjector.KeyCodeEve nt to ()
EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));
^
6 errors
Error!: Error: java compiler failed: javac -source 1.3 -target 1.1 -g -O -d C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\rapc_126410c4.d ir -bootcl ...
Error while building project

Can you please say which JDE you were using ?

Quote:
Originally Posted by Quincy View Post
EventInjector is part of the regular device system api, so importing the system api and then doing:

EventInjector.invokeEvent( new EventInjector.KeyCodeEvent(EventInjector.KeyCodeEv ent.KEY_DOWN , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));

EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char) NativeConstants.KEY_SEND, KeypadListener.STATUS_NOT_FROM_KEYPAD));

should work perfectly, as it is for me.

note: NativeConstants and Keypad constants are interchangeable
Offline  
Old 07-11-2008, 11:53 AM   #13 (permalink)
New Member
 
Join Date: Jun 2008
Model: 9550
PIN: N/A
Carrier: Rogers
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try compiling it in the Blackberry JDE if you are currently using a different jde. Use the Keypad constants in the place of the native constants if they aren't working in 4.3 which I'm not sure they do.

AND, you also need to specify a time parameter to hold the key during the event:

Code:
         EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_DOWN , (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100));
        EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100));
This is working for me on the simulator and a real 8320
Offline  
Old 07-11-2008, 12:29 PM   #14 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Quincy

I will try that

Also can you please check my post

How to modify the information displayed when a call incoming

I think there is some error in my PhoneListener app

Can you please check that particular post ?
Offline  
Old 07-11-2008, 01:38 PM   #15 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

It is not working for me even after I specified a time parameter
Offline  
Old 07-11-2008, 03:29 PM   #16 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Quincy

Thanks very much

It has compiled error free now

Quote:
Originally Posted by Quincy View Post
Try compiling it in the Blackberry JDE if you are currently using a different jde. Use the Keypad constants in the place of the native constants if they aren't working in 4.3 which I'm not sure they do.

AND, you also need to specify a time parameter to hold the key during the event:

Code:
         EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_DOWN , (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100));
        EventInjector.invokeEvent( new EventInjector.KeyCodeEvent( EventInjector.KeyCodeEvent.KEY_UP , (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD, 100));
This is working for me on the simulator and a real 8320
Offline  
Old 08-04-2008, 08:19 AM   #17 (permalink)
New Member
 
Join Date: Mar 2007
Model: 7250
Carrier: Orange
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi!

This method seems to work for Blackberrys with OS 4.2 (8100, 8800, 8300) but it failed to work on a BB 8110 with OS 4.3. On one Blackberry forum the official answer from RIM was that it's not possible to end a call through the RIM api, so maybe they've disabled it in the BB os 4.3?
Do you have a solution for ending a call for these newer Blackberrys?
Offline  
Old 08-07-2008, 10:59 AM   #18 (permalink)
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by szleventee View Post
Hi!

This method seems to work for Blackberrys with OS 4.2 (8100, 8800, 8300) but it failed to work on a BB 8110 with OS 4.3. On one Blackberry forum the official answer from RIM was that it's not possible to end a call through the RIM api, so maybe they've disabled it in the BB os 4.3?
Do you have a solution for ending a call for these newer Blackberrys?
Event injection mimics user entered events, so the issue with the 8110 that maybe you aren't seeing with the other models is that maybe the key sequence is not the same. You will have to find out how the call is ended on the 8110 and use the proper event injection for it (when I worked on 7000 series blackberries, I had to inject two trackwheel clicks for instance).

As for the RIM response, that's always been their stance. Devs were never "officially" allowed to end a call. I can confirm that in the simulator as late as 4.5 it should work, however, IT policies on actual devices and other settings make it not worth using in my opinion because of how unreliable it is(as you have witnessed).

Last edited by PaoloLim : 08-07-2008 at 11:01 AM.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.