skip to Main Content

I am using cordova-plugin-statusbar to change statusbar background color and statusbar text color but its not working on Android 13

I have added cordova-plugin-statusbar then i have used this code



document.addEventListener('deviceready', SetStatusBarColor, false);

function SetStatusBarColor() {

    StatusBar.overlaysWebView(false);

    StatusBar.backgroundColorByHexString("#ffffff");

    // Set the status bar text color to black

    StatusBar.styleDefault();

}

I need statusbar background color to white and status bar text color to black but its not working on Android 13.
On the other hand its working for Android 12 for first time after installing the app when I relaunch the app statusbar text color not changed into black only background color changed

2

Answers


  1. Any update on this yet? I’m facing the exact same issue. For me setting a timeout inside "deviceready" of about 2 Seconds and doing the StatusBar stuff afterwards works. I modified your example to reflect my solution:

    document.addEventListener('deviceready', setTimeout(SetStatusBarColor, 2000), false);
    
    function SetStatusBarColor() {
    
        StatusBar.overlaysWebView(false);
    
        StatusBar.backgroundColorByHexString("#ffffff");
    
        // Set the status bar text color to black
    
        StatusBar.styleDefault();
    
    }
    

    This is however not at all best practise, so I’d like to find a different solution. Would you mind posting an issue on the GitHub repository of the statusbar-plugin? (https://github.com/apache/cordova-plugin-statusbar)

    Login or Signup to reply.
  2. Same issue here. Setting timeout works but not a great solution. Tried setting "overlaysWebView" to false and changing the order of function calls but nothing worked.

    EDIT:
    just created an issue for this: https://github.com/apache/cordova-plugin-statusbar/issues/266

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search