6

Black screen came for 2 seconds when starting app in phonegap in android before the splash screen came. How to resolve this problem? I need splash screen immediately.

M Reza Saberi
  • 7,134
  • 9
  • 47
  • 76
user3323791
  • 79
  • 1
  • 4

4 Answers4

4

You need to create a new theme to the android app. Under "{Project}\res\values" create a new file "styles.xml" and put the contents of the attached imageenter image description here

In the AndroidManifest.xml add "android:theme="@style/Theme.MyAppTheme"" to the "application" tag

George
  • 125
  • 7
  • Please copy the actual contents of the file, as text, into your answer. – HughHughTeotl Jun 11 '15 at 08:13
  • I added the styles.xml file as recommended, and updated application.xml. However it seems that application.xml gets overwritten when making a build (at least when using Ionic.) To get around that I used the cordova-custom-config plugin to add the new theme to config.xml instead, as seen in Kutomer's answer here: http://stackoverflow.com/questions/29490925/change-android-theme-from-cordova-config-xml – Anthony Tietjen Feb 12 '17 at 02:58
  • 1
    To make it easier for the next person, here is a slimmed down text version of George's image. – Anthony Tietjen Feb 12 '17 at 03:00
1

Simply you can't.

That black screen is a sort of Android internal base screen that Android shows for your app while it fork a process in the Dalvik JVM and load your resources/classes. it happen for any Android app. it is not related to Phonegap. Android make this to give the user the impression of a "fast app launch" while it instead is still loading your code.

Anyway you can style that black screen to make it appear as near as possible to the theme of your app so the user have the impression the app is ready and launched but it is loading internal content.

You can read more about it here: http://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/

Alex
  • 1,237
  • 3
  • 18
  • 29
1

I had the same problem. Here's I solved it:

  1. Install the "org.apache.cordova.splashscreen" plugin

  2. Add these lines to your config.xml:

<preference name="AutoHideSplashScreen" value="false"/> <preference name="SplashScreenDelay" value="10000" /> <gap:plugin name="org.apache.cordova.splashscreen" />

  1. Change the config.xml's XML namespace from xmlns:cdv="http://cordova.apache.org/ns/1.0 to xmlns:gap="http://phonegap.com/ns/1.0, if not done so already.
Evan Wieland
  • 1,445
  • 1
  • 20
  • 36
Himanshu Garg
  • 599
  • 9
  • 21
0
<resources>
    <style name="AppBaseTheme" parent="android:Theme.Light" />
    <style name="Theme" parent="android:style/Theme" />
    <style name="Theme.MyAppTheme" parent="Theme">
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowBackground">@drawable/screen</item>
    </style>
</resources> 
Anzhelika
  • 111
  • 1
  • 5