如何对Android中的活动强制执行自定义权限? [英] How to enforce the custom permission on an Activity in Android?
问题描述
我在android中创建了一个自定义权限:
I have created a custom permission in android as:
<permission
android:name="com.master.me.CUSTOM_PERMISSION_TEST"
android:description="@string/des_permission"
android:label="labelhere">
</permission>
我将如何在 AndroidManifest.xml中的Activity中强制执行此操作
file?
How will I enforce this in my Activity in AndroidManifest.xml
file?
推荐答案
使用 android:permission
属性进入活动标签。
Use android:permission
attribute into activity tag.
如下所示
<activity android:permission="com.master.me.CUSTOM_PERMISSION_TEST"
android:name=".YourActivity"
android:label="@string/activity_label" />
您需要添加 uses-permission
当您的其他应用程序需要启动此活动时,您的自定义权限。
And you need to add uses-permission
to your custom permission, when your other application needs to launch this activity.
<uses-permission android:name="com.master.me.CUSTOM_PERMISSION_TEST"/>
深入介绍
Android权限模型 是了解Android版权限的好文章。 如何在Android中使用自定义权限?也是一个非常好的SO线程。
An In-Depth Introduction to the Android Permission Model is a very good article to understand permission in Android. And How to use custom permissions in Android? is also a very good SO thread.
这篇关于如何对Android中的活动强制执行自定义权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!