gpt4 book ai didi

android - 停止 SMS 传播

转载 作者:太空宇宙 更新时间:2023-11-03 12:42:40 28 4
gpt4 key购买 nike

我试图在收到这样的短信时不传播

public class SMSReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
abortBroadcast();
setResultData(null);
}
}

AndroidManifest.xml

<receiver android:name=".SMSReceiver" android:enabled="true" android:priority = "100" >
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

但这行不通。几天来我一直在寻找修复方法。非常感谢任何帮助。

谢谢

最佳答案

您需要设置 android:priority <intent-filter> 上的属性, 而不是 <receiver> .

例如

<intent-filter android:priority="9999" >

Use this attribute only if you really need to impose a specific order in which the broadcasts are received, or want to force Android to prefer one activity over others. The value must be an integer, such as "100". Higher numbers have a higher priority. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)

http://developer.android.com/guide/topics/manifest/intent-filter-element.html

关于android - 停止 SMS 传播,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4919578/

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