2

we are looking for a way to do the following:

  • user with BB enters a number (or selects a contact and clicks 'send')
  • our app in the background detects the call event
  • our app does something (e.g. blocks the call / makes a call to a different number, etc)

can this be done at all? can it be done transparently to the user (i.e. no dialogs or user involvement)? which APIs should I look at?

Thanks

Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
OS.
  • 358
  • 4
  • 11

1 Answers1

6

Outgoing call interception

call interception http://img200.imageshack.us/img200/6927/callinit.png

Code example:

import net.rim.blackberry.api.phone.Phone;
import net.rim.blackberry.api.phone.PhoneListener;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.component.Dialog;

public class CatchCall extends Application implements PhoneListener {
    public CatchCall() {
        Phone.addPhoneListener(this);
    }
    public static void main(String[] args) {
        new CatchCall().enterEventDispatcher();
    }
    public void callAdded(int callId) {
    }
    public void callAnswered(int callId) {
    }
    public void callConferenceCallEstablished(int callId) {
    }
    public void callConnected(int callId) {
    }
    public void callDirectConnectConnected(int callId) {
    }
    public void callDirectConnectDisconnected(int callId) {
    }
    public void callDisconnected(int callId) {
    }
    public void callEndedByUser(int callId) {
    }
    public void callFailed(int callId, int reason) {
    }
    public void callHeld(int callId) {
    }
    public void callIncoming(int callId) {
    }
    public void callInitiated(int callid) {
        Dialog.inform("call initiated");
    }
    public void callRemoved(int callId) {
    }
    public void callResumed(int callId) {
    }
    public void callWaiting(int callid) {
    }
    public void conferenceCallDisconnected(int callId) {
    }
}

Cancel call

You can use event injection to fire Close button press event:

public void dropCall()
{
    KeyEvent inject = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
    inject.post();
}

Don't forget to set permissions for device release: Options => Advanced Options => Applications => [Your Application] =>Edit Default permissions =>Interactions =>key stroke Injection

See also
BlackBerry - Simulate a KeyPress event

Community
  • 1
  • 1
Maksym Gontar
  • 22,765
  • 10
  • 78
  • 114
  • thanks - that's great! Do you know if there is a way to drop the call after catching the event? – OS. Sep 25 '09 at 20:40