gpt4 book ai didi

android - PROCESS_OUTGOING_CALLS 如何阻止调用发生?安卓

转载 作者:太空宇宙 更新时间:2023-11-03 11:52:55 24 4
gpt4 key购买 nike

如何在特定时间停止从 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系统还是会打电话的。在这个演示中,我只想让系统停止调用所有电话。

最佳答案

使用这个:

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);
}
}

关于android - PROCESS_OUTGOING_CALLS 如何阻止调用发生?安卓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7364112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com