【发布时间】:2018-05-10 23:50:07
【问题描述】:
我已经阅读了 stackoverflow 中的几个问题,包括 this、this 和 this,但它们并没有帮助我解决我的问题。
我已经在 android manifest 中描述了我的广播接收器以接收传入的 SMS,但它在 6.0(Marshmallow) 和 7.0(Noughat) 版本中不起作用,但它在 4.0 等较低版本中起作用。
我的应用程序有权在 manifest 和 在运行时授予权限 中读取和接收 SMS,但是我的 Broacast 接收器的 onReceive 永远不会被触发。我还尝试将优先级设置为 MAX_INT(即 2147483647),但没有帮助。
这是我在清单中的广播接收器描述:
<receiver
android:name="com.package.receiver.IncomingSms"
android:enabled="true"
android:permission="android.permission.READ_SMS">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
【问题讨论】:
-
我不确定您对以下答案的评论是什么意思,但是您在 sn-p 中的
permission属性不正确。该属性指定广播发送者 必须拥有的权限。如果你在其中包含一个,它必须是BROADCAST_SMS一个。
标签: android broadcastreceiver android-6.0-marshmallow android-7.0-nougat