Permission Denial , even after adding the correct permission in the manifest

有些话、适合烂在心里 提交于 2019-12-05 13:37:38

OK the problem is in your manifest. My working SMS broadcast receiver has the following manifest entry:

<receiver
    android:name=".IncomingSmsBroadcastReceiver"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

You do not need an android:permission attribute on the receiver. You just need the following permission to receive the broadcast and be able to look at the contents of the message:

<uses-permission android:name="android.permission.RECEIVE_SMS" />

The thing most often missed is android:exported="true" when declaring the receiver which is required as you are receiving a broadcast that originates from outside your own application. Needless to say, the default for this property is 'false'. Happy SMS Receiving.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!