List of usage examples for android.hardware.display DisplayManager getDisplays
public Display[] getDisplays()
From source file:com.mathi_amorim.emmanuel.metrictime.UpdateTimeService.java
public boolean isScreenOn() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { DisplayManager dm = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE); boolean screenOn = false; for (Display display : dm.getDisplays()) { if (display.getState() != Display.STATE_OFF) { screenOn = true;/*ww w.java 2s . co m*/ } } return screenOn; } else { PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); //noinspection deprecation return pm.isScreenOn(); } }
From source file:org.chromium.ChromeSystemDisplay.java
private void getInfo(final CordovaArgs args, final CallbackContext callbackContext) { cordova.getThreadPool().execute(new Runnable() { @Override//from w w w. j av a 2s .c om public void run() { try { JSONArray ret = new JSONArray(); try { DisplayManager displayManager = (DisplayManager) cordova.getActivity() .getSystemService(Activity.DISPLAY_SERVICE); Display[] displays = displayManager.getDisplays(); for (Display display : displays) { JSONObject displayInfo = new JSONObject(); displayInfo = getDisplayInfo(display); ret.put(displayInfo); } } catch (NoClassDefFoundError e) { Display defaultDisplay = cordova.getActivity().getWindowManager().getDefaultDisplay(); JSONObject displayInfo = new JSONObject(); displayInfo = getDisplayInfo(defaultDisplay); ret.put(displayInfo); } callbackContext.success(ret); } catch (Exception e) { Log.e(LOG_TAG, "Error occured while getting display info", e); callbackContext.error("Could not get display info"); } } }); }