Identify GoogleTv from Android app

后端 未结 4 1578
不知归路
不知归路 2020-12-17 20:54

Is there a way for an Android app to tell in the Java code if it is running on GoogleTV vs tablets or phones?

4条回答
  •  死守一世寂寞
    2020-12-17 21:39

    You can ask the package manager:

    /**
     * Test if this device is a Google TV.
     * 
     * See 32:00 in "Google I/O 2011: Building Android Apps for Google TV"
     * http://www.youtube.com/watch?v=CxLL-sR6XfM
     * 
     * @return true if google tv
     */
    public static boolean isGoogleTV(Context context) {
        final PackageManager pm = context.getPackageManager();
        return pm.hasSystemFeature("com.google.android.tv");
    }
    

    Plus this manifest line:

    
    

提交回复
热议问题