Reputation: 11164
I'm using this code to hide the top status bar
public static void removeNotificationBar(Activity activity) {
if (activity != null) {
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
But it seems I need to enable it back on in some cases in my activity and I am unable ti figure out what flags to pass to the window to re-enable the status bar.
Any ideas?
Upvotes: 1
Views: 80
Reputation: 9103
You have two options to solve your problem:
the first one: is to clear the flag, as described in this answer you can use:
activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
the second one: as this flag is in the activity scope, you can rerun the activity without any animation so that the user won't be able to figure out that the activity is re-initiated:
Intent intent = getIntent();
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(intent);
finish();
activity.overridePendingTransition(0, 0); // to restart the activity with No Animation
Upvotes: 2