[Android] Add util methods for PlayServices & RemoteControl

Geoffrey Métais git at videolan.org
Wed Feb 10 09:36:21 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb  9 18:18:13 2016 +0100| [490f65a9dbeb90d341316cd5ee73c8d313ed8285] | committer: Geoffrey Métais

Add util methods for PlayServices & RemoteControl

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

 .../src/org/videolan/vlc/util/AndroidDevices.java     | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 8114ca5..34efd5d 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -21,7 +21,9 @@
 package org.videolan.vlc.util;
 
 import android.annotation.TargetApi;
+import android.content.ComponentName;
 import android.content.Context;
+import android.content.pm.PackageManager;
 import android.net.ConnectivityManager;
 import android.net.NetworkInfo;
 import android.os.Build.VERSION;
@@ -34,6 +36,7 @@ import android.view.MotionEvent;
 
 import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.vlc.R;
+import org.videolan.vlc.RemoteControlClientReceiver;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.media.MediaWrapper;
 
@@ -194,6 +197,14 @@ public class AndroidDevices {
         return 0;
     }
 
+    public static boolean hasPlayServices() {
+        try {
+            VLCApplication.getAppContext().getPackageManager().getPackageInfo("com.google.android.gsf", PackageManager.GET_SERVICES);
+            return true;
+        } catch (PackageManager.NameNotFoundException e) {}
+        return false;
+    }
+
     public static boolean hasLANConnection() {
         boolean networkEnabled = false;
         ConnectivityManager connectivity = (ConnectivityManager) (VLCApplication.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE));
@@ -206,4 +217,12 @@ public class AndroidDevices {
         }
         return networkEnabled;
     }
+
+    public static void setRemoteControlReceiverEnabled(boolean enabled) {
+        VLCApplication.getAppContext().getPackageManager().setComponentEnabledSetting(
+                new ComponentName(VLCApplication.getAppContext(), RemoteControlClientReceiver.class),
+                enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
+                        PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+                PackageManager.DONT_KILL_APP);
+    }
 }



More information about the Android mailing list