Open Jmalinza opened 6 years ago
Solved: make sure you have included
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
in you manifest file as well as a run-time permission checker which can ask the user for permission:
//check permissions
public boolean checkPermissionExtertalStorage() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int result = getApplicationContext().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
return result == PackageManager.PERMISSION_GRANTED;
}
return false;
}
//permission dialog
public void requestPermissionExtertalStorage() throws Exception {
try {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
REQUEST_CODE);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
The activity is always returning a result code of -1. I've tried using logcat and Toast but it seems that the onCreate() function of FileChooserActivity doesn't even post the toast or logcat message.
I'm so confused because the GUI launches, so onCreate() must be executing. Included my code for starting the activity and dealing with the results.