Android的广播安全安全、Android

2023-09-04 03:45:20 作者:ゞ鱄屬ㄨ緈諨

在Android中,你可以设置一个广播的行动,几乎所有的东西(节省系统的操作。)我的问题是你怎么从你的欺骗广播prevent其他应用程序?假设你有一个名为com.a.b.c的动作。其他应用程序应该得到com.abc,但他们不应该是能够发送com.abc怎么会这样呢?

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 have an action called "com.a.b.c". Other applications should receive com.a.b.c, but they shouldn't be able to send com.a.b.c. How can that be done?

另外,我要求澄清了处理广播接收权限。我觉得Android的文档有点混乱与此有关。有没有一种方法,使一个允许其他应用程序必须有接收com.abc?就像在清单中指定com.abcpermission供他人使用。

Also, I seek clarification of permissions that deal with broadcast reception. I find the Android documentation a bit confusing with this. Is there a way to make a permission that other applications have to have to receive com.a.b.c? Like specifying com.a.b.cpermission in the manifest for others to use.

推荐答案

您可以使用LocalBroadcastManager的https://developer.android.com/reference/android/support/v4/content/LocalBroadcastManager.html

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

你也可以定义在清单的权限。而使用http://developer.android.com/reference/android/content/Context.html#sendBroadcast%28android.content.Intent,%20java.lang.String%29发送广播,它要求你com.abc权限将收到那么只有应用程序。但是,这是公开的API您的应用程序,要小心这种方式。

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.