在哪里可以找到有关android特定权限的更多信息

编程入门 行业动态 更新时间:2024-10-11 23:18:06
本文介绍了在哪里可以找到有关android特定权限的更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要从minSdkVersion ="19"升级旧的Android应用程序,因此我需要处理所有权限.

I need to upgrade old android aplication from minSdkVersion="19" , so I need to handle all the permissions.

在清单中,它需要一些危险的权限.例如:

In the manifest, it requires some dangerous permissions. e.g.:

<uses-permission android:name="android.permission.BLUETOOTH" /> <!-- normal --> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- normal --> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <!-- normal --> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- dangerous --> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" /> <!-- ??? --> <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- normal --> <uses-permission android:name="android.permission.INTERNET" /> <!-- normal --> <uses-permission android:name="android.permission.VIBRATE" /> <!-- normal --> <uses-permission android:name="android.permission.CAMERA" /> <!-- dangerous --> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- dangerous --> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- dangerous --> <android:uses-permission android:name="android.permission.READ_PHONE_STATE" /> <!-- dangerous --> <android:uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="18" /> <!-- dangerous -->

  • 如何在代码中找到需要这些危险权限的地方?是否有取决于每个权限的功能列表?

  • How can I find in code where these dangerous permissions are needed? Is there a list of functions that depends on each permission?

    关于 MOUNT_UNMOUNT_FILESYSTEMS -在哪里可以找到它是危险的还是正常的?

    Regarding MOUNT_UNMOUNT_FILESYSTEMS - where can I find if it is dangerous or normal?

    推荐答案

    在回答具体问题之前,我要说一下,如果普通用户将使用您的应用程序(即从Google Play或其他商店下载该应用程序),那么许多权限可能会吓跑用户.从这个问题看来,您好像继承了别人的代码,甚至不需要其中的某些权限.

    Before answering the specific questions, let me say that if your app is to be used by normal users (i.e. download it from Google play or other stores) listing so many permissions will probably scare users away. From the question it sounds like you inherit someone else's code, and some of those permissions are not even needed.

    这里要注意的另一重要事项是第三方应用程序(例如,您从Google Play商店下载的应用程序)与电话制造商的应用程序(购买时安装在手机上的大多数应用程序)之间的区别.

    Another important thing to notice here is the difference between 3rd party apps (for example, apps you download from Google's play store) and phone-manufacturer apps (most of the apps installed on your phone when you buy it).

    制造商应用可以使用第三方不能使用的权限.

    Manufacturer apps can use permissions that 3rd parties can't.

    对您的问题:

  • 我不记得所有具有所需权限的功能的完整列表.也许其他人可以在这里启发我们两个人:)面向Android M及更高版本的代码应使用 ContextCompat.checkSelfPermission(Context,String)之类的函数包装所有危险"行为,并检查是否已授予权限,以避免运行时 SecurityException s.但是在旧代码中发现危险"行为几乎是不可能的,主要是因为Android OS与开发人员的协议是您只需要在清单中请求这些权限,并且我将确保不会抛出运行时安全异常".恐怕这里需要手动搜索.

  • I don't recall a complete list for functionalities with needed permission for each. Maybe someone else can enlighten both of us here :) Code targeting Android M and above SHOULD wrap any "dangerous" behaviour with a check that permission is granted, using functions like ContextCompat.checkSelfPermission(Context, String) in order to avoid runtime SecurityExceptions. But finding "dangerous" behaviors in old code is almost impossible, mainly because Android OS's agreement with the developers was "you just request those permissions in the manifest and I will make sure no runtime security exceptions will be thrown". A manual search is in need here, I'm afraid.

    这是来自Android官方文档的所有可用权限的完整列表-

    Here is a complete list of all available permissions, from Android official documentation -

    developer.android/reference/android/Manifest.permission

    请注意,第三方应用程序会忽略MOUNT_UNMOUNT_FILESYSTEM权限,因此(除非您为Samsung或Xiaomi工作),您可以从清单中安全删除此权限.

    Notice that MOUNT_UNMOUNT_FILESYSTEM permission is ignored for 3rd party apps, so (unless you work for e.g. Samsung or Xiaomi) you can safely delete this permission from your manifest.

  • 还请注意,如果您请求FINE_LOCATION权限,则无需同时请求COARSE_LOCATION权限.
  • 更多推荐

    在哪里可以找到有关android特定权限的更多信息

    本文发布于:2023-11-07 10:21:42,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1566198.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:更多信息   可以找到   权限   android

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!