对于Twilio Android客户端未启动来电的PendingIntent

时间:2015-06-12 00:28:27

标签: android android-intent twilio android-pendingintent

在Twilio android客户端的示例应用程序中,我无法接收传入的呼叫。我正在使用节点js服务器。请求在我的服务器和twilio之间路由,甚至我能够看到twilio呼叫日志中的呼叫状态。但是,当我调用twilio客户端时,Android设备上看不到任何内容。我认为pendingIntent启动时存在问题。有人可以帮帮我吗?

// 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 个答案:

没有答案