等待未在Twilio android客户端中调用的意图

时间:2015-06-12 17:54:22

标签: android twilio android-pendingintent

我在Twilio中使用示例android client进行语音通话。我可以从Android客户端进行拨出电话。但是无法接听任何来电。呼叫在我的服务器和twilio之间正确路由,甚至显示在呼叫日志中,但不调用活动。有人可以帮助我。我认为未决意图存在一些问题。

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

没有答案