Android中的权限使用情况

时间:2012-08-06 17:16:12

标签: android android-intent permissions

我需要保持谨慎,只有我的应用可以向我的IntentService广播意图。如何使用Android权限制作它?

我在gcm android库中看到类似的权限用法,但我不明白它是如何工作的。

2 个答案:

答案 0 :(得分:3)

如果您希望自己的任何应用都可以使用此服务(多个应用),但其他应用无法使用 您需要实现基于签名的权限。

声明您自己的自定义签名权限

<permission android:description="string resource"
android:icon="drawable resource"
android:label="string resource"
android:name="string"
android:permissionGroup="string"
android:protectionLevel="signature" />

然后使用

在BroadcaseReceiver中强制执行此权限
android:permission="string"  
接收器中的

标签,甚至可以在任何其他组件中执行此操作,例如活动等。

然后在您想要访问上述功能的其他应用中,可以在其清单中声明使用权限。 请记住:您的第二个应用必须使用相同的证书进行签名才能使用基于自定义签名的权限 在此处详细了解权限:http://developer.android.com/guide/topics/security/permissions.html

答案 1 :(得分:0)

请参阅:

http://developer.android.com/guide/components/services.html

  

如果您打算仅在本地使用您的服务(其他应用程序可以   不使用它),那么你不需要(也不应该)提供任何意图   过滤器。没有任何意图过滤器,您必须使用启动服务   显式命名服务类的意图。

只是不要在你的清单中放置任何Intent过滤器......

相关问题