在 Twilio Android 客户端中未调用挂起意图

2023-12-10

我正在使用示例安卓客户端在 Twilio 中进行语音通话。我可以从 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);
        }   
    }

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Twilio Android 客户端中未调用挂起意图 的相关文章

随机推荐