View Single Post
Old 07-04-2008, 10:36 AM   #34
MobileDeveloper
Thumbs Must Hurt
 
Join Date: Jun 2008
Model: 8100
PIN: N/A
Carrier: Vodafone
Posts: 134
Default

Hello

I tried compling it but it is giving me error

cannot find symbol
symbol : variable KeyCodeEvent


Do I have to import any library ?


Code:
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\MyPhone.java" "C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\icon.png"
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPhone.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_KEYPAD, 10);
                                                                                    ^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPhone.java:31: internal error; cannot instantiate KeyCodeEvent(int,char,int,int) at net.rim.device.api.system.EventInjector.KeyCodeEvent to ()
            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD, 10);
                                                     ^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPhone.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_KEYPAD, 10);
                                                                                      ^
C:\Documents and Settings\Administrator\My Documents\RACProjs\BBerrySample\CallListener\MyPhone.java:32: internal error; cannot instantiate KeyCodeEvent(int,char,int,int) at net.rim.device.api.system.EventInjector.KeyCodeEvent to ()
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END,KeypadListener.STATUS_NOT_FROM_KEYPAD, 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.dir -bootcl ...
Error while building project
Quote:
Originally Posted by samwize View Post
Hi

I have developed a similar application that disconnect call and do a callback. You may download it at Hoiio. I would appreciate for any feedback.

But it seems like there are a lot of bugs surrounding PhoneListener, simulating key events to disconnect call and Invoke call event. I noticed two bugs:

1) There is a 'Ghost Call Effect', in which sometimes (randomly) after the call is disconnected with event injection, but the phone still shows 'Calling ...', but in fact is not dialling anymore! This will lead to another effect where the next incoming call received will be muted.

2) callInitiated callback event is called twice. I need to have a lock to prevent the extra event.

If someone experienced the same problem as me, let me know! Some of the code that you might be looking for and which I have tested to work in 4.2 and 4.3 are posted below. callInitiated does get the callback when a call is made.

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;
}
Code:
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);
}
Offline   Reply With Quote