I have tried every thing but for some reason following code fails to hide the status bar on the android device.
the ionic vue beep app, joule app are able to do it in a way but my code fails on the same device. what is wrong then here ?
import { Component } from "@angular/core";
import { Platform } from "@ionic/angular";
import { SplashScreen } from "@ionic-native/splash-screen/ngx";
import { StatusBar } from "@ionic-native/status-bar/ngx";
@Component({
selector: "app-root",
templateUrl: "app.component.html"
})
export class AppComponent {
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.overlaysWebView(true);
if (window.statusbar) {
this.statusBar.hide();
}
this.statusBar.backgroundColorByHexString("#ffffff");
// this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
}
i am building the app with capacitor.
i get the following error in browser inspect,
Angular is running in the development mode. Call enableProdMode() to enable the production mode. core.js:16829
Native: tried calling StatusBar.overlaysWebView, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator common.js:290
Native: tried calling StatusBar.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator common.js:290
Native: tried calling StatusBar.backgroundColorByHexString, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator common.js:290
Native: tried calling SplashScreen.hide, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator common.js:290
in android studio i add this line in style.xml
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:background">@null</item>
<item name="android:windowFullscreen">true</item>
</style>
this works … so what was the actual issue here ? or is it compulsory to add this line in style.xml in android studio before compiling ?
i hope people searching for a solution can now not waste more time on this …