【问题标题】:Intent.action_call didn't work in BroadcastReceiver on Galaxy S3Intent.action_call 在 Galaxy S3 上的 BroadcastReceiver 中不起作用
【发布时间】:2012-06-20 08:41:41
【问题描述】:

我有拨号应用程序,当用户拨打号码以+开头时,它会挂断然后拨打特定号码。我在 BroadcastReceiver 的 onReceive 中执行此操作,代码如下。

public void onReceive(Context context, Intent intent) {
    to = intent.getStringExtra("android.intent.extra.PHONE_NUMBER");
    if (to == null)
        return;

    if (to.startsWith("+")) {
        setResultData(null);

        Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123456789"));
                callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(callIntent);

        Toast toast = Toast.makeText(context, "Call trap and Redirect", Toast.LENGTH_LONG);
        toast.show();
        return;
    }

}

此代码在其他型号上工作正常,但在 Galaxy S3 上不工作。 Toast 消息显示但 intent.action_call 未拨出???只是安静,logcat没有错误。

只有在从广播接收器内部启动意图时才会发生这种情况,从活动启动时,intent.action_call 将正常工作。有什么想法吗?

【问题讨论】:

  • 需要更多信息,是否有问题,没有发生什么?
  • Antony,实际上我使用 onReceive 的上下文参数
  • Jox Traex,有什么不对的,它应该拨打新号码,但它不仅仅是安静。
  • 我在 HTC 上遇到了同样的问题。你解决了吗?

标签: android broadcastreceiver galaxy


【解决方案1】:

我在使用 Galaxy S3(GT-I9300) 时遇到了同样的问题。 我尝试启动新活动而不是触发 ACTION_CALL(我的代码最初也触发 ACTION_CALL,但修改为调试)。在这种情况下,它可以与调试器一起使用,但如果没有调试器附件则无法使用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-15
    • 1970-01-01
    • 2014-06-15
    • 2016-06-28
    • 1970-01-01
    • 2020-05-17
    相关资源
    最近更新 更多