Home » Android » android – status bar flicker when exiting fullscreen activity

android – status bar flicker when exiting fullscreen activity

Posted by: admin June 16, 2020 Leave a comment

Questions:

I noticed a pretty irritating flicker that happens in the following scenario: display a fullscreen activity and then launch another activity that is not fullscreen.

In my app I use an action bar at the top of the second activity and I clearly see how a flickering is done when switching between the activities.

When the status bar appears, it doesn’t smoothly push my activity down, but very quickly and with this annoying flicker.

Is there some API I can use to control this behaviour?
Or some other workaround?

How to&Answers:

I had same issue.
Below workaround fixed it, put this code before finishing your first activity.

Handler handler = new Handler();
handler.post(new Runnable() {
    @Override
    public void run() {
        YourActivity.this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    }
});