在下载我的应用程序(如 ES 文件资源管理器文件管理器)之前,如何在我的 android 应用程序中请求许可?

How to ask for permission in my android app within playstore before downloading my app(Like ES File Explorer File Manager)?

我想在我的 android 应用程序中添加访问文件和用户位置的权限。现在,当用户打开我的应用程序时,它会请求权限,但如果用户拒绝,我的应用程序将无法正常运行,因为他 phone 中下载了图片。给人不好的影响。现在我想问一下,在下载我的应用程序(如 ES 文件资源管理器文件管理器)之前,我如何在 Playstore 中请求我的应用程序的许可。如果用户否认这一点,他将无法安装我的应用程序。

您可以通过选择 API22 作为目标 SDK 来实现

If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.

但也

Note: Beginning with Android 6.0 (API level 23), users can revoke permissions from any app at any time, even if the app targets a lower API level. You should test your app to verify that it behaves properly when it's missing a needed permission, regardless of what API level your app targets.

来源:https://developer.android.com/training/permissions/requesting.html

If the device is running Android 5.1 or lower, or your app's target SDK is 22 or lower: If you list a dangerous permission in your manifest, the user has to grant the permission when they install the app; if they do not grant the permission, the system does not install the app at all.

因此,我认为您可以将目标 SDK 和目标 API 设置为低于 22 以使用旧权限系统。

您必须在 AndroidManifest.xml 中添加一些使用权限。 像这样:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
//for file access
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
//for location access and updates
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
</manifest>

添加这些权限后,您必须创建新的发布版本并 post 才能播放商店。 注意:这些权限在 API 级别低于 23 时工作正常,但对于 API 23 或更高级别,您必须检查 运行-time 权限(棉花糖和牛轧糖),以获取有关请求权限的更多信息在 运行 时间请完成此 link-https://developer.android.com/training/permissions/requesting.html