PendingIntent for Incoming call not getting launched for Twilio Android client

51 views Asked by At

In the sample application for the Twilio android client,I am not being able to receive incoming calls.I am using node js for the server.The request is being routed between my server and twilio and even I am able to see the call status in the twilio call logs. But when I call a twilio client,nothing is seen on the android device. I think there is a problem with the pendingIntent getting launched. Can anybody help me out?

//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