[Android] Marshmallow permission request for TV
Geoffrey Métais
git at videolan.org
Tue Oct 27 17:47:02 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Oct 22 16:31:40 2015 +0200| [23f25f40e273e7d2aa027000d85ffbcd9e903d2b] | committer: Geoffrey Métais
Marshmallow permission request for TV
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=23f25f40e273e7d2aa027000d85ffbcd9e903d2b
---
.../org/videolan/vlc/gui/tv/MainTvActivity.java | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index d491734..85f49d9 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -23,6 +23,7 @@ package org.videolan.vlc.gui.tv;
import android.app.Activity;
import android.app.FragmentManager;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
@@ -111,6 +112,8 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
return;
}
+ AndroidDevices.checkReadStoragePermission(this, false);
+
mContext = this;
setContentView(R.layout.tv_main_fragment);
@@ -182,6 +185,25 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
}
@Override
+ public void onRequestPermissionsResult(int requestCode,
+ String permissions[], int[] grantResults) {
+ switch (requestCode) {
+ case AndroidDevices.PERMISSION_STORAGE_TAG: {
+ // If request is cancelled, the result arrays are empty.
+ if (grantResults.length > 0
+ && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ refresh();
+ } else {
+ AndroidDevices.showStoragePermissionDialog(this, false);
+ }
+ return;
+ }
+ // other 'case' lines to check for other
+ // permissions this app might request
+ }
+ }
+
+ @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
More information about the Android
mailing list