mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix external storage read permissions bug
Fix bug which causes the PlayerActivity to finish whenever the android.permission.READ_EXTERNAL_STORAGE permission is requested. A better solution would involve not requesting permissions if a previous request is still pending. This would involve keeping extra state in the activity, so this solution is used to keep the demo app's complexity at a minimum. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=192588821
This commit is contained in:
parent
3c78dc22f6
commit
7d0067e298
1 changed files with 9 additions and 4 deletions
|
|
@ -215,12 +215,17 @@ public class PlayerActivity extends Activity
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||||
@NonNull int[] grantResults) {
|
@NonNull int[] grantResults) {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0) {
|
||||||
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
initializePlayer();
|
initializePlayer();
|
||||||
} else {
|
} else {
|
||||||
showToast(R.string.storage_permission_denied);
|
showToast(R.string.storage_permission_denied);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// Empty results are triggered if a permission is requested while another request was already
|
||||||
|
// pending and can be safely ignored in this case.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activity input
|
// Activity input
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue