简体   繁体   English

AndroidManifest.xml 中的最大 Android 权限

[英]Maximum Android permissions in AndroidManifest.xml

Adding a lot of permissions doesn't cause problems, as far as I know.据我所知,添加大量权限不会引起问题。 So why a developer should not be asking for all the available permissions, Including unnecessary ones?那么为什么开发人员不应该要求所有可用的权限,包括不必要的权限?

I noticed that Android doesn't ask for the user's permissions for some of the permissions.我注意到 Android 并没有要求用户获得某些权限。 What's the reason for that?这是什么原因?

You must follow the Permissions best practices.您必须遵循权限最佳实践。

  1. You must specify in your Manifest only the permissions that you need.您必须在您的清单中仅指定您需要的权限。 If you ask for not necessary ones or too many then users will most likely remove your app even before they fully run it.如果您要求不必要的或太多,那么用户很可能会在他们完全运行之前删除您的应用。

  2. Is better to request each Permission or group of Permissions whenever is first needed.最好在第一次需要时请求每个权限或权限组。 Though, if it's just a couple of permissions probably you can ask for them right away at start time.不过,如果它只是几个权限,您可能可以在开始时立即请求它们。

  3. The fact that a Permission is declared in the Manifest doesn't mean it is Granted, it only means that the app will require it.在清单中声明权限的事实并不意味着它被授予,这仅意味着应用程序将需要它。 And yes, you still need to ask each to be granted.是的,您仍然需要要求每个人都被授予。

  4. A practical example.一个实际的例子。 A camera app:一个相机应用程序:

    • The first time it runs should ask for the storage and camera permissions, so it can take photos and write them to file.它第一次运行时应该询问存储和相机权限,以便它可以拍照并将它们写入文件。
    • Then the user changes to video mode, at this point you can ask for the Audio permission, so videos can be recorded with audio.然后用户切换到视频模式,此时你可以请求音频权限,这样视频就可以带音频录制了。
    • Probably the app can have an extra option in its settings window, which may allow to save the GPS location in the EXIF data.该应用程序可能在其设置窗口中有一个额外的选项,可以允许将 GPS 位置保存在 EXIF 数据中。 So, when accessing such setting the app may ask for the Location permission.因此,在访问此类设置时,应用程序可能会要求位置权限。

This may sound at first glance like a lot of requests at different points, but this is how is specified by the best practices.乍一看,这听起来像是在不同点有很多请求,但这就是最佳实践所指定的方式。 Permissions should be requested in a way that doesn't overwhelm the user.应以不会让用户不知所措的方式请求权限。

More details in next link: https://developer.android.com/training/permissions/usage-notes下一个链接中的更多详细信息: https : //developer.android.com/training/permissions/usage-notes

And a final clarification.以及最后的澄清。 If a specific API call requires a permission which isn't granted, then an Exception will be thrown at the moment that such API call gets executed.如果特定的 API 调用需要未授予的权限,则在执行此类 API 调用时将抛出异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Android Studio的AndroidManifest.xml中添加权限? - Adding Permissions in AndroidManifest.xml in Android Studio? AndroidManifest.xml 中的权限在 Flutter 中被忽略 - Permissions in AndroidManifest.xml are ignored in Flutter 如何为AndroidManifest.xml添加权限以进行测试 - How to Add Permissions to AndroidManifest.xml for Tests 摆脱 AndroidManifest.xml 中不必要的权限 - Getting rid of unneccessary permissions in AndroidManifest.xml 如何更改Androidmanifest.xml中的默认权限 - How to change the default permissions in Androidmanifest.xml Cordova向AndroidManifest.xml添加不必要的权限 - Cordova adds unnecessary permissions to AndroidManifest.xml Android React Native App 请求未在 android/app/src/main/AndroidManifest.xml 中定义的权限 - Android React Native App asking for permissions that are not defined within android/app/src/main/AndroidManifest.xml 如何在Android设备中安装的应用程序的AndroidManifest.xml文件中获取权限? - How do I get permissions only in AndroidManifest.xml file for installed apps in android device? Unity3D 如何为 android 插件添加权限到 AndroidManifest.xml - Unity3D how to add permissions to AndroidManifest.xml for android plugin Android 应用程序 - AndroidManifest.xml 不起作用 - Android App - AndroidManifest.xml does not work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM