How to determine if an Android device has a screen, is it an Android set-top box?

I know you can get screen sizes, but I would like to know if anyone could ever find out if an Android device has a screen or not. that is, whether it is a prefix or not.

I assume that the screen size that should be returned should be β€œzero”, but I'm not sure if this is really the answer in the real world.

Thanks.

+6
source share
2 answers

You can check the availability of the TV device .

public static final String TAG = "DeviceTypeRuntimeCheck"; UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) { Log.d(TAG, "Running on a TV Device"); } else { Log.d(TAG, "Running on a non-TV Device"); } 
+5
source

When viewing the code, paste this code:

  int screenSize = getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; String toastMsg; switch(screenSize) { case Configuration.SCREENLAYOUT_SIZE_LARGE: toastMsg = "Large screen"; break; case Configuration.SCREENLAYOUT_SIZE_NORMAL: toastMsg = "Normal screen"; break; case Configuration.SCREENLAYOUT_SIZE_SMALL: toastMsg = "Small screen"; break; default: toastMsg = "Screen size is neither large, normal or small"; } Toast.makeText(this, toastMsg, Toast.LENGTH_LONG).show(); 

You can determine the screen size of toastMsg .

0
source

Source: https://habr.com/ru/post/985833/


All Articles