Android 10,11 文件存储
https://blog.csdn.net/zw904448290/article/details/114316496
存储目录
https://www.cnblogs.com/whoislcj/p/6137398.html
https://blog.csdn.net/Motejia/article/details/114697683
存储的目录
https://blog.csdn.net/jyfjyt/article/details/87105233
android 11 定位权限 ACCESS_BACKGROUND_LOCATION
Android 11将位置权限分为前台和后台两种权限。前文说的主要是前台权限,授权方式没有变化。应用想要申请后台权限,除了需要在清单文件中额外添加 ACCESSBACKGROUNDLOCATION 权限外,还需要应用主动引导用户到指定页面授权。
。
https://lbs.amap.com/api/android-location-sdk/guide/utilities/permision_11
实例代码
@TargetApi(30)
private fun Context.checkBackgroundLocationPermissionAPI30(backgroundLocationRequestCode: Int) {
if (checkSinglePermission(Manifest.permission.ACCESS_BACKGROUND_LOCATION)) return
AlertDialog.Builder(this)
.setTitle(R.string.background_location_permission_title)
.setMessage(R.string.background_location_permission_message)
.setPositiveButton(R.string.yes) { _,_ ->
// this request will take user to Application's Setting page
requestPermissions(arrayOf(Manifest.permission.ACCESS_BACKGROUND_LOCATION), backgroundLocationRequestCode)
}
.setNegativeButton(R.string.no) { dialog,_ ->
dialog.dismiss()
}
.create()
.show()
}
可以做个判断 弹框提示用户 去设置里面获取权限
if (Build.VERSION.SDK_INT == 30 && "android.permission.ACCESS_BACKGROUND_LOCATION".equals(permissions[0])){
showSettings("需要后端定位权限", Settings.ACTION_SETTINGS);
}
各个系统 获取位置权限
https://blog.csdn.net/zwluoyuxi/article/details/109485098
存储权限适配
https://www.jianshu.com/p/e94cea26e213?utm_campaign=haruki
https://blog.csdn.net/Motejia/article/details/114697683
Android11 更新了新的存储权限分区存储,
其中Android10 时候也对存储权限做了更新android:requestLegacyExternalStorage="true"
当我们升级到Android11时候,首先在清单文件中的application声明:
android:requestLegacyExternalStorage="true"
android:preserveLegacyExternalStorage="true"//升级保留旧版存储权限
然后在声明权限:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/>//可读取所有包名
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
//设备文件广泛访问,核心用例app
然后在Activity中进行所有文件存储访问权限:
//Android11存储
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
startActivity(intent);
}
网友评论