gpt4 book ai didi

java - 如何在 Android 中对 Activity 强制执行自定义权限?

转载 作者:IT老高 更新时间:2023-10-28 20:39:03 26 4
gpt4 key购买 nike

我在android中创建了一个自定义权限:

<permission
android:name="com.master.me.CUSTOM_PERMISSION_TEST"
android:description="@string/des_permission"
android:label="labelhere">
</permission>

我将如何在 AndroidManifest.xml 文件中的 Activity 中强制执行此操作?

最佳答案

在 Activity 标签中使用 android:permission 属性。

如下图

<activity android:permission="com.master.me.CUSTOM_PERMISSION_TEST"
android:name=".YourActivity"
android:label="@string/activity_label" />

当您的其他应用程序需要启动此 Activity 时,您需要将 uses-permission 添加到您的自定义权限中。

<uses-permission android:name="com.master.me.CUSTOM_PERMISSION_TEST"/>

An In-Depth Introduction to the Android Permission Model是一篇很好的了解Android中权限的文章。和How to use custom permissions in Android?也是一个很好的SO线程。

关于java - 如何在 Android 中对 Activity 强制执行自定义权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21693480/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com