【问题标题】:Accepting incoming call twilio(Obtain the name to client who made the call)接受来电 twilio(获取拨打电话的客户的姓名)
【发布时间】:2013-12-13 10:56:10
【问题描述】:

我正在使用 twilio 开发一个简单的语音聊天 Android 应用程序。我能够拨打电话,也可以使用客户端名称接听来电。这是我的 twilio 语音 url php 脚本:

<?php
header('Content-type: text/xml');
$client= $_REQUEST["userName"];

 ?>
<Response>
    <Dial callerId="<?php echo $client ?>">
        <Client><?php echo $number;?></Client>
    </Dial>
</Response>

我需要做的是向接收来电的用户显示呼叫客户端的名称,但我无法弄清楚如何获取呼叫客户端的名称。我什至尝试过这样做,

 @Override
        public void onResume() {
            super.onResume();

            Intent intent = getIntent();
            Device device = intent.getParcelableExtra(Device.EXTRA_DEVICE);
            Connection incoming = intent
                    .getParcelableExtra(Device.EXTRA_CONNECTION);
            incoming.setConnectionListener(this);
                    String clientName =  Connection.getParameters().get(incoming.IncomingParameterFromKey);

            Log.i(TAG, "Call from : " + clientName);
        }

但我得到了以下 logcat 输出:

12-13 16:17:25.531: E/Voice chat sample app log(16157): Call from : 873797

我收到的是一个号码 873797,而不是客户名称。

可能有一些方法可以获取客户端的名称。我还浏览了 twilio 文档,但没有成功。任何帮助将不胜感激。

【问题讨论】:

  • 您找到解决方案了吗?

标签: android twilio


【解决方案1】:

您只需访问此链接

https://www.twilio.com/user/account/phone-numbers/incoming

   1. Click on your twilio number. 
   2. Enter into the Configure Tab
  3. Go into Voice . Check the Url in Configure with:
  4. Over there you have a drop down of Caller Name Lookup that is set to disabled. Enable it .

希望这对你有用! :)

【讨论】:

    【解决方案2】:

    我已经解决了这个问题,

    希望对你有帮助

    @Override
    public void onResume() {
        super.onResume();
    
        Intent intent = getIntent();
    
        if (intent != null) {
            /*
             * Determine if the receiving Intent has an extra for the incoming connection. If so,
             * remove it from the Intent to prevent handling it again next time the Activity is resumed
             */
            Device device = intent.getParcelableExtra(Device.EXTRA_DEVICE);
            Connection incomingConnection = intent.getParcelableExtra(Device.EXTRA_CONNECTION);
            if (incomingConnection == null && device == null) {
                return;
            }
            intent.removeExtra(Device.EXTRA_DEVICE);
            intent.removeExtra(Device.EXTRA_CONNECTION);
    
            pendingConnection = incomingConnection;
            pendingConnection.setConnectionListener(this);
    
            String incomingRecipientCallNumber = pendingConnection.getParameters().get(incomingConnection.IncomingParameterFromKey);
    
            showRecipientNumber.setText(incomingRecipientCallNumber);
    
            showIncomingDialog();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-17
      相关资源
      最近更新 更多