[Android] Close video player on BACK evt with resume dialog

Geoffrey Métais git at videolan.org
Fri Oct 12 17:13:21 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Oct 12 17:11:53 2018 +0200| [23ca742aeb69c351b92e7046e2131e50b7a5aa54] | committer: Geoffrey Métais

Close video player on BACK evt with resume dialog

Fix #659

> https://code.videolan.org/videolan/vlc-android/commit/23ca742aeb69c351b92e7046e2131e50b7a5aa54
---

 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java    | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 82b340fce..3da2502a8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2948,8 +2948,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     }
 
     public void showConfirmResumeDialog() {
-        if (isFinishing())
-            return;
+        if (isFinishing()) return;
         mService.pause();
         /* Encountered Error, exit player with a message */
         mAlertDialog = new AlertDialog.Builder(VideoPlayerActivity.this)
@@ -2966,6 +2965,17 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
                 })
                 .create();
         mAlertDialog.setCancelable(false);
+        mAlertDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
+            @Override
+            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
+                if (keyCode == KeyEvent.KEYCODE_BACK) {
+                    dialog.dismiss();
+                    finish();
+                    return true;
+                }
+                return false;
+            }
+        });
         mAlertDialog.show();
     }
 



More information about the Android mailing list