BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-05-2008, 04:23 AM   #1
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 12:47 PM   #2
aux
New Member
 
Join Date: May 2008
Model: 8100
PIN: N/A
Carrier: mtel
Posts: 8
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, 12:58 PM   #3
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Default

Hi

I would try it

Thanks very much for your help
Offline  
Old 07-08-2008, 01:57 PM   #4
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 12:44 AM   #5
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
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, 04:23 AM   #6
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 04:45 AM   #7
arunk
Talking BlackBerry Encyclopedia
 
arunk's Avatar
 
Join Date: Mar 2008
Model: 8310
PIN: N/A
Carrier: Airtel
Posts: 229
Cool

you have to import EventInjector, Keypad, KeyCodeEvent... classes to the application. Just check that...
Offline  
Old 07-09-2008, 05:00 AM   #8
simon.hain
CrackBerry Addict
 
Join Date: Apr 2005
Location: hamburg, germany
Model: 8900
Carrier: o2
Posts: 838
Default

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

Hi

I had declared

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

It was still giving me errors
Offline  
Old 07-10-2008, 03:23 PM   #10
Quincy
New Member
 
Join Date: Jun 2008
Model: 9550
PIN: N/A
Carrier: Rogers
Posts: 12
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, 06:00 AM   #11
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 08:59 AM   #12
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 10:53 AM   #13
Quincy
New Member
 
Join Date: Jun 2008
Model: 9550
PIN: N/A
Carrier: Rogers
Posts: 12
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, 11:29 AM   #14
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Default

Hi Quincy

I will try that

Also can you please check my post

http://www.blackberryforums.com/deve...-incoming.html

I think there is some error in my PhoneListener app

Can you please check that particular post ?
Offline  
Old 07-11-2008, 12:38 PM   #15
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Default

Hi

It is not working for me even after I specified a time parameter
Offline  
Old 07-11-2008, 02:29 PM   #16
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
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, 07:19 AM   #17
szleventee
New Member
 
Join Date: Mar 2007
Model: 7250
Carrier: Orange
Posts: 12
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, 09:59 AM   #18
PaoloLim
New Member
 
Join Date: Jun 2008
Model: 7290
PIN: N/A
Carrier: Cingular
Posts: 14
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 10: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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Schneider Electric Energy Server EBX510 Server For Energy Management- picture

Schneider Electric Energy Server EBX510 Server For Energy Management-

$4350.00



MEDIA SERVER DOLBY IMS2000 MSIP-REM-DIB-IMS2000 picture

MEDIA SERVER DOLBY IMS2000 MSIP-REM-DIB-IMS2000

$799.99



New In Box DELL T640 06KK42 Server Fan GPU Upgrade Fan Kit picture

New In Box DELL T640 06KK42 Server Fan GPU Upgrade Fan Kit

$300.24



Weidmüller WI-MOD-945-E (6720005015) Wireless Ethernet & Serial Device Server picture

Weidmüller WI-MOD-945-E (6720005015) Wireless Ethernet & Serial Device Server

$129.99



Schneider Electric Energy Server EBX510 Server For Energy Management picture

Schneider Electric Energy Server EBX510 Server For Energy Management

$865.64



Axis Q7900 14 Slot Video Server Rack Chassis,Axis 0287-004 picture

Axis Q7900 14 Slot Video Server Rack Chassis,Axis 0287-004

$230.00







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