do not request WRITE permission since android 11 won't grant it to us anyway using native file IO
This commit is contained in:
parent
2df6fc57bf
commit
d1f99e5566
@ -33,10 +33,6 @@ import android.os.Bundle;
|
||||
|
||||
public class PermissionRequestActivity extends Activity {
|
||||
|
||||
/**
|
||||
* 'dangerous' permissions not granted by the manifest on versions >= M
|
||||
*/
|
||||
private static final String[] NEEDED_PERMISSIONS = { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE };
|
||||
/**
|
||||
* The intent to start after acquiring the required permissions
|
||||
*/
|
||||
@ -48,7 +44,7 @@ public class PermissionRequestActivity extends Activity {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mCallbackIntent = getIntent().getExtras().getParcelable("callbackIntent");
|
||||
requestPermissions(NEEDED_PERMISSIONS, 0);
|
||||
requestPermissions(getNeededPermissions(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +127,7 @@ public class PermissionRequestActivity extends Activity {
|
||||
*/
|
||||
public static boolean havePermissions(Context context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
for (String permission : NEEDED_PERMISSIONS) {
|
||||
for (String permission : getNeededPermissions()) {
|
||||
if (context.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
|
||||
return false;
|
||||
}
|
||||
@ -140,4 +136,11 @@ public class PermissionRequestActivity extends Activity {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String[] getNeededPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
return new String[] { Manifest.permission.READ_EXTERNAL_STORAGE };
|
||||
}
|
||||
return new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE };
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user