Window window = MainActivity.this.getWindow();
window.setStatusBarColor(MY_COLOR_IT_CAN_BE_ANY);
if (Build.VERSION.SDK_INT < 30)
{
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
else {
window.setDecorFitsSystemWindows(false);
WindowInsetsController controller = getWindow().getInsetsController();
if(controller != null) {
controller.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS,
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS);
}
}
I am using this code for setting light status bar in android 11 and below android 11. Everything works fine, just a little problem, deprecation warning not going.