Reputation: 1281
I want to stop outgoing call and open the application. The app is able to listen new outgoing call. Now I don’t have any idea how to stop the call and open the app. Any help?
Upvotes: 0
Views: 525
Reputation: 221
Try this code it works fine for me. On your Outgoing call listener method use this code to disconnect call and after that code open your app.
public static void DisconnectCall()
{
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run()
{
try{
final EventInjector.KeyCodeEvent pressEndKey = new EventInjector.KeyCodeEvent(
KeyCodeEvent.KEY_DOWN, (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD);
final EventInjector.KeyCodeEvent releaseEndKey = new EventInjector.KeyCodeEvent(
KeyCodeEvent.KEY_UP, (char)Keypad.KEY_END, KeypadListener.STATUS_NOT_FROM_KEYPAD);
EventInjector.invokeEvent (pressEndKey);
Thread.sleep(100);
EventInjector.invokeEvent (releaseEndKey);
Thread.sleep(100);
}catch (Exception e)
{
e.printStackTrace();
}
}
});
}
Upvotes: 1
Reputation: 9804
You cannot pause it, but you can do whatever you want when a call is initiated, by the following 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 CallInterrupting extends Application implements PhoneListener {
public CallInterrupting() {
Phone.addPhoneListener(this);
}
public static void main(String[] args) {
new CallInterrupting().enterEventDispatcher();
}
public void callAdded(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callAnswered(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callConferenceCallEstablished(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callConnected(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callDirectConnectConnected(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callDirectConnectDisconnected(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callDisconnected(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callEndedByUser(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callFailed(int callId, int reason) {
// DO WHATEVER YOU WANT HERE
}
public void callHeld(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callIncoming(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callInitiated(int callid) {
// A CALL IS INITIATED HERE, PUT YOUR CODE !
}
public void callRemoved(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callResumed(int callId) {
// DO WHATEVER YOU WANT HERE
}
public void callWaiting(int callid) {
// DO WHATEVER YOU WANT HERE
}
public void conferenceCallDisconnected(int callId) {
// DO WHATEVER YOU WANT HERE
}
}
If you mean to totally cancel/drop the call, set permissions for device as follows:
Then call the following function in the desired catched event:
public void cancellingCall()
{
KeyEvent inject = new KeyEvent(KeyEvent.KEY_DOWN, Characters.ESCAPE, 0);
inject.post();
// OPEN YOUR APP HERE
}
Upvotes: 2