I'm using Cordova's StatusBar and SplashScreen. I want the app to launch fullscreen i.e. status bar to be hidden when the app launches.
In the deviceready
callback, I'm invoking StatusBar.hide()
and later on I use StatusBar.show()
to show the status bar again. This works fine.
The issue is when the splash image appears, the status bar is visible. And when the deviceready
callback if fired, the status bar hides. I even tried setting Fullscreen preference in config.xml to true, but the result is same. Hide at Startup configuration is also related to iOS only.
Is there a way (using Cordova only) to launch the app without status bar and show it later on?
Note: I'm using SplashScreen plugin to show splash screen
Find MainActivity.java in
\platforms\android\app\src\main\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 snippet from Hyuck answer on : Ionic 3 - Hide status bar during splash screen show
it's do the job for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With