1
我有撥號應用程序,當用戶撥打號碼以+開頭時,它會掛斷然後呼叫特定號碼。我在以下代碼的onReceive of BroadcastReceiver中執行此操作。Intent.action_call在Galaxy S3上的BroadcastReceiver中不起作用
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上沒有問題。吐司消息顯示,但intent.action_call不撥出?只是安靜,logcat沒有錯誤。
只有當從broadcastreceiver內部開始intent時纔會發生這種情況,intent.action_call在從activity開始時會正常工作。任何想法?
需要更多信息,出了什麼問題,什麼不會發生? – JoxTraex
安東尼,實際上我使用onReceive – user1084081
Jox Traex的上下文參數,它應該打電話給新號碼,但它不只是安靜。 – user1084081