[Android] Restart the service when the steal remote control option changes
Sébastien Toque
git at videolan.org
Tue Nov 6 22:32:56 CET 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Tue Nov 6 22:25:55 2012 +0100| [50111b4bc4030beee8b7159db3e2a21ca669554f] | committer: Sébastien Toque
Restart the service when the steal remote control option changes
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=50111b4bc4030beee8b7159db3e2a21ca669554f
---
.../org/videolan/vlc/gui/PreferencesActivity.java | 23 ++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
index 33fe473..848cacc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PreferencesActivity.java
@@ -23,6 +23,7 @@ package org.videolan.vlc.gui;
import java.io.File;
import java.util.ArrayList;
+import org.videolan.vlc.AudioService;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.DatabaseManager;
import org.videolan.vlc.LibVLC;
@@ -32,6 +33,7 @@ import org.videolan.vlc.Util;
import android.app.AlertDialog;
import android.app.Dialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -243,6 +245,17 @@ public class PreferencesActivity extends PreferenceActivity {
}
});
+ // steal remote control
+ Preference checkboxStealRC = findPreference("steal_remote_control");
+ checkboxStealRC.setOnPreferenceClickListener(
+ new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ restartService(preference.getContext());
+ return true;
+ }
+ });
+
// Change verbosity (logcat)
CheckBoxPreference checkboxVerbosity = (CheckBoxPreference) findPreference("enable_verbose_mode");
checkboxVerbosity.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@@ -320,4 +333,14 @@ public class PreferencesActivity extends PreferenceActivity {
super.onPause();
AudioServiceController.getInstance().unbindAudioService(this);
}
+
+ private void restartService(Context context) {
+ Intent service = new Intent(context, AudioService.class);
+
+ AudioServiceController.getInstance().unbindAudioService(PreferencesActivity.this);
+ context.stopService(service);
+
+ context.startService(service);
+ AudioServiceController.getInstance().bindAudioService(PreferencesActivity.this);
+ }
}
More information about the Android
mailing list