Dhairya Vora
Dhairya Vora

Reputation: 1281

Blackberry - Interrupt outgoing call

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

Answers (2)

Nsr
Nsr

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

Ashraf Bashir
Ashraf Bashir

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:

  1. Options
  2. Advanced Options
  3. Applications
  4. APP_NAME
  5. Edit Default permissions
  6. Interactions
  7. key stroke Injection

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

Related Questions