android how to change / reset status bar color

android how to change / reset status bar color
ref‮ual:ot re‬tturi.com
public static void changeStatusBarColor(Activity context, boolean change, int color){
    Window window = context.getWindow();
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);

    if(change){ 
        // change the color of status bar 
        defaultStatusBarColor = window.getStatusBarColor();
        window.setStatusBarColor(color);
    }
    else{
        // reset the color of status bar 
        window.setStatusBarColor(defaultStatusBarColor);
    }
    
}
Created Time:2017-10-07 21:51:07  Author:lautturi