mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +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,11 +215,16 @@ public class PlayerActivity extends Activity
|
|||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
initializePlayer();
|
||||
if (grantResults.length > 0) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
initializePlayer();
|
||||
} else {
|
||||
showToast(R.string.storage_permission_denied);
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
showToast(R.string.storage_permission_denied);
|
||||
finish();
|
||||
// Empty results are triggered if a permission is requested while another request was already
|
||||
// pending and can be safely ignored in this case.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue