I want to change the color of status bar,and did the same as specified here . 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.
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 >= 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);
}
}
}
when the condition is false, i am resetting