Ask the app to listen to our feed ACTION_SCREEN_OFF. More info here .
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
}
}
}
You might also want to get information about when a user passed the key lock by registering for ACTION_USER_PRESENT .
source
share