Pending intent not getting invoked in Twilio android client

限于喜欢 提交于 2019-12-02 12:31:12

问题


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);
        }   
    }

来源:https://stackoverflow.com/questions/30809358/pending-intent-not-getting-invoked-in-twilio-android-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!