`
notfatboy
  • 浏览: 235421 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Security and Permissions安全与权限(六)

阅读更多

Enforcing Permissions when Sending Broadcasts

In addition to the permission enforcing who can send Intents to a registered BroadcastReceiver (as described above), you can also specify a required permission when sending a broadcast. By calling Context.sendBroadcast() with a permission string, you require that a receiver's application must hold that permission in order to receive your broadcast.

Note that both a receiver and a broadcaster can require a permission. When this happens, both permission checks must pass for the Intent to be delivered to the associated target.

除了之前说过的Permission(用于限制谁才可以发送广播给相应的broadcastReceiver),你还可以在发送广播的时候指定一个permission。在调用Context.sendBroadcast() 的时候使用一个permission string,你就可以要求receiver的宿主程序必须有相应的permission。

值得注意的是Receiver和broadcaster都可以要求permission。当这种情况发生时,这两种permission检查都需要通过后才会将相应的intent发送给相关的目的地。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics