Cordoba - StatusBar is hidden at startup - Android

I am using Cordova StatusBar and SplashScreen . I want the application to start full screen mode, i.e. The status bar was hidden when the application started.

In the deviceready I call StatusBar.hide() , and later I use StatusBar.show() to display the status bar again. It works great.

The problem is when a popup image appears, a status bar is displayed. And with the deviceready at startup, the status bar is hidden. I even tried setting Fullscreen in config.xml to true, but the result is the same. Hide at Startup configuration is also only associated with iOS.

Is there a way (using only Cordoba) to launch the application without a status bar and show it later?

Note. I use the SplashScreen plugin to display a splash screen

+7
source share
1 answer

Find MainActivity.java in

\ Platforms \ Android \ application \ SRC \ home \ Java \ COM \ yourpackage \ name

add this to the import section:

 import android.view.WindowManager; 

then add this code to the last line:

 public class MainActivity extends CordovaActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // enable Cordova apps to be started in the background Bundle extras = getIntent().getExtras(); if (extras != null && extras.getBoolean("cdvStartInBackground", false)) { moveTaskToBack(true); } // [Hyuck] add this two line below getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // Set by <content src="index.html" /> in config.xml loadUrl(launchUrl); } // [Hyuck] onStart() is totally new. @Override public void onStart() { super.onStart(); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } } 

This is a snippet from Hook’s answer to: Ionic 3 - Hide status bar while showing screen saver

it does the job for me.

0
source

Source: https://habr.com/ru/post/1257788/


All Articles