Intercept an outgoing call to Blackberry
we are looking for a way to do the following:
- user with BB enters a number (or selects a contact and clicks "Submit")
- our application in the background detects a call event
- our application does something (for example, blocks a call / makes a call to another number, etc.)
Can this be done at all? can this be done transparently to the user (i.e. no dialog or user interaction)? which APIs should I be looking at?
thank
+2
source to share
1 answer
Interception of outgoing calls
call interception http://img200.imageshack.us/img200/6927/callinit.png
- create Application extension for background service
- implement PhoneListener
- use callInitiated
- must be signed before using on the device
- should be tested against a known issue
Sample code:
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 an event to start a fire. Click the close button:
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 app] => Change default permissions => Interactions => key stroke Injection
See Also
BlackBerry - Simulate KeyPress Event
+6
source to share