private void registerScreenActionReceiver(){
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
registerReceiver(receiver, filter);
}
private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(final Context context, final Intent intent) {
// Do your action here
}
};
final IntentFilter filter = new IntentFilter();
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_SCREEN_ON);
registerReceiver(receiver, filter);
}
private final BroadcastReceiver receiver = new BroadcastReceiver(){
@Override
public void onReceive(final Context context, final Intent intent) {
// Do your action here
}
};