[Android] Method to check if app is running on Android TV

Geoffrey Métais git at videolan.org
Wed Jan 20 11:24:43 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Jan 20 10:49:36 2016 +0100| [e4dbcd9b5f4d96766e9a53a0263b1286be3e806a] | committer: Geoffrey Métais

Method to check if app is running on Android TV

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

 vlc-android/src/org/videolan/vlc/VLCApplication.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index d28d8e3..11671e0 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -45,6 +45,9 @@ public class VLCApplication extends Application {
     public final static String SLEEP_INTENT = Strings.buildPkgString("SleepIntent");
 
     public static Calendar sPlayerSleepTime = null;
+
+    private static boolean sTV;
+
     /* Up to 2 threads maximum, inactive threads are killed after 2 seconds */
     private ThreadPoolExecutor mThreadPool = new ThreadPoolExecutor(0, 2, 2, TimeUnit.SECONDS,
                                                                     new LinkedBlockingQueue<Runnable>());
@@ -89,6 +92,8 @@ public class VLCApplication extends Application {
         MediaDatabase.getInstance();
         // Prepare cache folder constants
         AudioUtil.prepareCacheFolder(this);
+
+        sTV = getPackageManager().hasSystemFeature("android.software.leanback");
     }
 
     /**
@@ -118,6 +123,10 @@ public class VLCApplication extends Application {
         return instance.getResources();
     }
 
+    public static boolean isTv() {
+        return sTV;
+    }
+
     public static void runBackground(Runnable runnable) {
         instance.mThreadPool.execute(runnable);
     }



More information about the Android mailing list