7

I want to set my android app status bar to light background and dark text. It is working perfectly when I view my app in Phonegap mobile app. But after building the app and installing in mobile it's not working. I'm using Android 7.

I tried with Cordova version 4, 5 & 7. This didn't work in any version.

I used below code in config

<preference name="StatusBarBackgroundColor" value="#F1F1F1" />
<preference name="StatusBarStyle" value="default" />

I've also tried using javascript in index.js after the device ready

StatusBar.backgroundColorByHexString("#F1F1F1");
StatusBar.styleDefault();

I tried removing the plugin and installed the latest code from github as suggested by related posts in StackOverflow. Nothing is working. Any suggestions?

Also, Is there any fallback code to handle android versions below 6? I came to know that those versions doesn't support dark text in status bar.

bharat
  • 330
  • 1
  • 3
  • 13

1 Answers1

1

Use this plugin. Make sure that your device is ready first..

example:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(StatusBar);
}

Note: This installation method requires cordova 5.0+

For example check this link. There is also live app.

If this did't help, let me know

proofzy
  • 627
  • 1
  • 12
  • 23
  • I'm using the same plugin and invoking the required methods after device ready. It isn't working. – bharat May 22 '18 at 16:32
  • Did you tried remove cordova and add it again and check is it higher than version 5.0? – proofzy May 23 '18 at 10:23
  • How can I check the version of cordova in phonegap? I'm not using CLI. is there any other way to check the version and update the cordova without using CLI? – bharat May 23 '18 at 20:21
  • Then you should found cordova version file, for example C:\Users\Ivan\Desktop\MyApp\platforms\browser\cordova\version ... Press right click on version file and open with Notepad++ .. [example](https://imgur.com/a/vaW90UX) – proofzy May 24 '18 at 08:29
  • For simple using you should download node.js and run cmd typing `npm info cordova version` .. To update cordova use `npm update -g cordova` – proofzy May 24 '18 at 08:35
  • I updated my Cordova version from 4 to 5. The issue is not resolved :( – bharat May 26 '18 at 14:37