aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorThanasis Antoniou2019-10-07 23:54:24 +0300
committerThanasis Antoniou2019-10-08 00:02:12 +0300
commitbd969478f8f90f845e05d9f0089c3a9ec50165d1 (patch)
treee3d2a03e3aa75e3dda35fb1a3a4afcd52b3f8d13 /backends/platform
parenteabb81829f29716e949890844029567687626bc8 (diff)
downloadscummvm-rg350-bd969478f8f90f845e05d9f0089c3a9ec50165d1.tar.gz
scummvm-rg350-bd969478f8f90f845e05d9f0089c3a9ec50165d1.tar.bz2
scummvm-rg350-bd969478f8f90f845e05d9f0089c3a9ec50165d1.zip
ANDROID: Ask for external storage access onCreate()
This is a quick fix, it needs to be improved upon With this fix on devices with API >= Marshmallow (6.0.1) the ScummVM app will ask for the permission during runtime onCreate(), and not only when trying to browse the list of folders and files. However, it is only a quick fix, because the original behavior will still kick in and the prompt to Quit because no SD Card was detected will be displayed anyway. So even if the user grants access during runtime, they will still be forced to exit the app and will have to relaunch.
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index 2d48dfa7b5..abced48562 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -193,6 +193,12 @@ public class ScummVMActivity extends Activity {
setContentView(R.layout.main);
takeKeyEvents(true);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
+ && checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
+ ) {
+ requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_READ_EXT_STORAGE);
+ }
+
// This is a common enough error that we should warn about it
// explicitly.
if (!Environment.getExternalStorageDirectory().canRead()) {
@@ -333,7 +339,7 @@ public class ScummVMActivity extends Activity {
Log.i(ScummVM.LOG_TAG, "Read External Storage permission was granted at Runtime");
} else {
// permission denied! We won't be able to make use of functionality depending on this permission.
- Toast.makeText(this, "Until permission is granted, some folders might not be listed!", Toast.LENGTH_SHORT)
+ Toast.makeText(this, "Until permission is granted, some storage locations may be inaccessible!", Toast.LENGTH_SHORT)
.show();
}
break;