Permission denial on BroadCast SMS intent

雨燕双飞 提交于 2019-12-10 11:38:53

问题


can my activity broadcast this intent from itself

Intent i = new Intent("android.provider.Telephony.SMS_RECEIVED");

sendBroadcast(i);

I am able to send this broadcast and receive it back (from a broadcast receiver setup in the application) , but this is not a global broadcast , i.e. it is not received by the default SMS application. furthermore i am getting this error in the logcat

Permission Denial: broadcasting Intent { act=android.provider.Telephony.SMS_RECEIVED } from com.smartanuj.scale (pid=3572, uid=10029) requires android.permission.BROADCAST_SMS due to receiver com.android.mms/com.android.mms.transaction.PrivilegedSmsReceiver

I have already specified

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

in my manifest file


回答1:


Only applications signed with the system key may broadcast the arrival of new SMS messages.




回答2:


You only need to have the BROADCAST_SMS privilege, and to generate the PDU by yourself. Then it works. You can find a summary here: http://blog.dev001.net/post/14085892020/android-generate-incoming-sms-from-within-your-app (second part, "Doing it by generating a SMS_RECEIVED broadcast").



来源:https://stackoverflow.com/questions/3819856/permission-denial-on-broadcast-sms-intent

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