【发布时间】: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