[AndroidTips]Android how to check screen off 判断屏幕是开还是关

pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
boolean screen = pm.isScreenOn();

 

如果你要监听屏幕开关的事件的话, 你需要监听这个两个ACTION_SCREEN_OFF and ACTION_SCREEN_ON intent broadcast

 

ref:http://stackoverflow.com/questions/7529733/how-to-discover-if-the-screen-is-on-or-off-while-developping-in-android

你可能感兴趣的:(android)