[Android] properly unbind from the service

Sébastien Toque git at videolan.org
Thu Nov 1 18:03:15 CET 2012


vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Thu Nov  1 18:00:55 2012 +0100| [8b8f4d6bc5d54152d356df48e8bb07d40c517968] | committer: Sébastien Toque

properly unbind from the service

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=8b8f4d6bc5d54152d356df48e8bb07d40c517968
---

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java |    1 +
 .../videolan/vlc/gui/video/VideoPlayerActivity.java    |   16 ++++++++--------
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index b0bc30a..55ca044 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -345,6 +345,7 @@ public class MainActivity extends SherlockFragmentActivity {
         editor.commit();
 
         mAudioController.removeAudioPlayer(mAudioPlayer);
+        AudioServiceController.getInstance().unbindAudioService(this);
     }
 
     @Override
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 23d89ab..0dc9f9c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -282,8 +282,13 @@ public class VideoPlayerActivity extends Activity {
     protected void onPause() {
         super.onPause();
 
-        if(mSwitchingView)
+        if(mSwitchingView) {
+            Log.d(TAG, "mLocation = \"" + mLocation + "\"");
+            AudioServiceController.getInstance().showWithoutParse(mLocation);
+            AudioServiceController.getInstance().unbindAudioService(this);
+            AudioPlayerActivity.start(this, true);
             return;
+        }
 
         long time = mLibVLC.getTime();
         long length = mLibVLC.getLength();
@@ -323,6 +328,8 @@ public class VideoPlayerActivity extends Activity {
                     DatabaseManager.mediaColumn.MEDIA_TIME,
                     time);
         }
+
+        AudioServiceController.getInstance().unbindAudioService(this);
     }
 
     @Override
@@ -337,13 +344,6 @@ public class VideoPlayerActivity extends Activity {
         em.removeHandler(eventHandler);
 
         mAudioManager = null;
-
-        if(mSwitchingView) {
-            Log.d(TAG, "mLocation = \"" + mLocation + "\"");
-            AudioServiceController.getInstance().showWithoutParse(mLocation);
-            AudioPlayerActivity.start(this, true);
-        }
-        //AudioServiceController.getInstance().unbindAudioService(this);
     }
 
     @Override



More information about the Android mailing list