Changing status bar color on HUAWEI device not working (API level 22)

1.3k views Asked by At

After testing my app on a HUAWEI Y538, I noticed something weird: the status bar is showing a strange gradient rather than the color I have intended. I have a pretty straight methodology for setting the status bar in my base activity class, which is the following:

protected void setStatusBarColor(int color) {
    Window window = getWindow();
    if (Build.VERSION.SDK_INT > 20) {
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(color);
    } 
}

Though, for some reason, this is not working on the HUAWEI phone. Does anyone have any insight as to why this could be happening. Thanks in advance!!

1

There are 1 answers

0
Ger On

It is the fault of the OS on your phone, and there is not much you can do about that.

Huawei has not implemented Lollipop 5.1.1 in EMUI 3.1, or rather from what I gather from other users and developers (see here, for example), it is not implemented consistently, as different apps may cause unpredictable effects, such as the one you describe. This answer offers a solution on the user end, but I cannot find anything that allows a developer to enforce color.