开发者

Blackberry - using EventInjector to ignore incoming call

Hello e开发者_开发知识库veryone' I'm trying to use an EventInjector in my app to automatically dismiss all incoming calls. My MainScreen implements PhoneListener. Below is my code

public void callIncoming(int callId) {
            requestForeground();
            final PhoneCall call = Phone.getCall(callId);  
            final String number = call.getDisplayPhoneNumber();  
            System.out.println(number);  
            EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(  
                    KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0, 100);  
            EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(  
                    KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END, 0, 100);

            EventInjector.invokeEvent(pressEndKey);  
            EventInjector.invokeEvent(releaseEndKey);   
        }

This code isn't working, in otherwords in has no effect. The incoming call screen continues to popup and won't go away until an action is taken.


Check this link, it works!

http://www.codinguru.com/2011/08/block-incoming-call-in-blackberry.html

public void callIncoming(int callId) {
        final PhoneCall call = Phone.getCall(callId);  
        final String number = call.getDisplayPhoneNumber();  
        System.out.println(number);  

        EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0, 100);  
        EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent( KeyCodeEvent.KEY_UP, (char) Keypad.KEY_END, 0, 100);  

        try {  
            Thread.sleep(1000);  
        } catch (InterruptedException e) {  
            // TODO Auto-generated catch block  
        e.printStackTrace();  
        }  
        EventInjector.invokeEvent(pressEndKey);  
        EventInjector.invokeEvent(releaseEndKey);  
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜