Android获取系统屏幕亮/灭屏状态

直接上代码

import android.os.PowerManager;

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
//如果不是在Activity里面需要得到当时的上下文句柄 用context.getSystemService...
boolean isScreenOn = pm.isScreenOn();

猜你喜欢

转载自phoobobo.iteye.com/blog/2264627