可以做些什么来在特定时间停止来自Android设备的特定号码的拨出电话。我使用以下权限:android.permission.PROCESS_OUTGOING_CALLS
但接收方无法停止呼叫
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<receiver android:name=".receiver.NewOutgoingCallReceiver" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
这是接收者代码:
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String incomingNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
Log.d("NewOutgoingCallReceiver",
">>>>>> Intent.EXTRA_PHONE_NUMBER: "
+ incomingNumber);
Toast.makeText(context, "Call - " + incomingNumber, Toast.LENGTH_LONG).show();
abortBroadcast();
}
Android系统仍会拨打电话。在这个演示中,我只想系统停止拨打所有电话。
答案 0 :(得分:10)
使用此:
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(OUTGOING_CALL_ACTION)) {
// get phone number from bundle
String phoneNumber = intent.getExtras().getString(INTENT_PHONE_NUMBER);
Toast.makeText(context, "Call: "+phoneNumber+" - ABORTING CALL.", Toast.LENGTH_LONG).show();
setResultData(null);
}
}