Android Broadcast Security

前端 未结 1 827
旧时难觅i
旧时难觅i 2021-01-28 20:44

In android, you can set the action of a broadcast to almost anything (save system actions.) My question is how can you prevent other apps from spoofing your broadcasts? Say you

1条回答
  •  佛祖请我去吃肉
    2021-01-28 21:30

    You can use LocalBroadcastManager https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html

    Also you can define permission in the manifest. And use http://developer.android.com/reference/android/content/Context.html#sendBroadcast%28android.content.Intent,%20java.lang.String%29 to send broadcast, then only apps which requested your "com.a.b.c" permission will receive. But this is public api to your app, be careful this way.

    0 讨论(0)
提交回复
热议问题