Problem:
We need to check if the screen of the phone is on or not.
Solution:
To implement that you have to follow this example. Please take note of the "isScreenOn" boolean variable.
@Override
protected void onPause()
{
super.onPause();
// If the screen is off then the device has been locked
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
boolean isScreenOn = powerManager.isScreenOn();
if (!isScreenOn) {
// The screen has been locked
// do stuff...
}
}
No hay comentarios:
Publicar un comentario