[Android] Set listener only when activity is active

Geoffrey Métais git at videolan.org
Thu Apr 28 11:17:16 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 28 10:39:03 2016 +0200| [eeafef9b664fccc0249b264747d997aa8ac19ea8] | committer: Geoffrey Métais

Set listener only when activity is active

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

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index e9b327f..b9ecbb0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -242,7 +242,6 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
 
     private void setupNavigationView() {
         mNavigationView = (NavigationView) findViewById(R.id.navigation);
-        mNavigationView.setNavigationItemSelectedListener(this);
         if (TextUtils.equals(BuildConfig.FLAVOR_target, "chrome")) {
             MenuItem item = mNavigationView.getMenu().findItem(R.id.nav_directories);
             item.setTitle(R.string.open);
@@ -293,12 +292,14 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
           //Deactivated for now
 //        createExtensionServiceConnection();
 
+        mNavigationView.setNavigationItemSelectedListener(this);
         clearBackstackFromClass(ExtensionBrowser.class);
     }
 
     @Override
     protected void onStop() {
         super.onStop();
+        mNavigationView.setNavigationItemSelectedListener(null);
         if (mExtensionServiceConnection != null) {
             unbindService(mExtensionServiceConnection);
             mExtensionServiceConnection = null;



More information about the Android mailing list