How to set and reset status bar color to original based on some condition in android
<p>I want to change the color of status bar,and did the same as specified <a href="https://stackoverflow.com/questions/27093287/how-to-change-status-bar-color-to-match-app-in-lollipop-android">here</a> . I have the following doubts.
1) but i want to reset status bar color to original based on some condition, how will i do that.
I have tried like this.</p>

<pre><code>public class StoreDisableHelper {

    public static void changeStatusBarColor(boolean status,Activity activity){
        Window window = activity.getWindow();
        if(status){


// clear FLAG_TRANSLUCENT_STATUS flag:
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

// add FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag to the window
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

// finally change the color
            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.LOLLIPOP) {
                window.setStatusBarColor(activity.getResources().getColor(R.color.theme_red));
            }

        }
        else{
            window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            window.clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        }

    }
}
</code></pre>

<p>when the condition is false, i am resetting</p>