Pending intent not getting invoked in Twilio android client

284 views Asked by At

I am using the sample android client in Twilio for making voice calls.I am able to do outgoing calls from the android client.But cannot receive any incoming call. The call is getting routed correctly between my server and twilio,and is even shown in the call logs,but activity is not invoked. Can somebody help me.I think there is some problem with the pending intent.

//MonkeyPhone.java

    public void onInitialized() {
            Log.d(TAG, "Twilio SDK is ready");
    try {
                capabilityToken = HttpHelper.httpGet("http://my server/token?client=jenny");
                device = Twilio.createDevice(capabilityToken, this);

            Intent intent = new Intent(context, HelloMonkeyActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                    intent, PendingIntent.FLAG_UPDATE_CURRENT);
            device.setIncomingIntent(pendingIntent);

            } catch (Exception e) {
                Log.e(TAG,"Failed to obtain capability token: "+ e.getLocalizedMessage());
            }
        }

//HelloMonkeyActivity.java

@Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
    }

    @Override
    protected void onResume() {
        super.onResume();
        Intent intent=getIntent();
        Device device=intent.getParcelableExtra(Device.EXTRA_DEVICE);
        Connection connection= intent.getParcelableExtra(Device.EXTRA_CONNECTION);
        Log.i("Hello monkey", "device and connection are:"+device+":"+connection);

        if(device!=null && connection!=null){
            intent.removeExtra(Device.EXTRA_DEVICE);
            intent.removeExtra(Device.EXTRA_CONNECTION);
            phone.handleIncomingConnections(device, connection);
        }   
    }
0

There are 0 answers