BroadCast Receiver calling intent after some time android
Posted
by
khushi
on Stack Overflow
See other posts from Stack Overflow
or by khushi
Published on 2012-04-16T11:25:31Z
Indexed on
2012/04/16
11:29 UTC
Read the original article
Hit count: 170
android
public class myReceiver extends BroadcastReceiver {
public static boolean wasScreenOn = true;
@Override
public void onReceive(final Context context, Intent recievedIntent) {
if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
wasScreenOn = false;
Intent intent = new Intent(context,
myActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
context.startActivity(intent
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else if (recievedIntent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
wasScreenOn = true;
}
}
}
The activity display after when action screen on is call.
© Stack Overflow or respective owner