Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap Status bar styleDefault & fall back for android below 6

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.

like image 324
bharat Avatar asked May 18 '18 06:05

bharat


People also ask

How can I change the color of my status bar in Cordova?

overlaysWebView to false, you can set the background color of the statusbar by a hex string (#RRGGBB). On Android, when StatusBar. overlaysWebView is true, and on WP7&8, you can also specify values as #AARRGGBB, where AA is an alpha value.

What is InAppBrowser?

Introducing InAppBrowser.com, a simple tool to list the JavaScript commands executed by the iOS app rendering the page. To try this this tool yourself: Open an app you want to analyze. Share the url https://InAppBrowser.com somewhere inside the app (e.g. send a DM to a friend, or post to your feed)

What is Cordova Android?

Cordova Android is an Android application library that allows for Cordova-based projects to be built for the Android Platform. Cordova based applications are, at the core, applications written with web technology: HTML, CSS and JavaScript. Apache Cordova is a project of The Apache Software Foundation (ASF).


1 Answers

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

like image 115
proofzy Avatar answered Sep 19 '22 02:09

proofzy