0

I am using the Google Android Development Tools (Eclipse) with the Phonegap 2.9 plugin to build an Android app. I want to get my app to show a splash screen. I am trying to follow the instructions on the Phonegap documentation for splash screens.

Problem one: I edited app/res/xml/config.xml accordingly. But, the instructions get vague at a point. It says:

Copy the splash screen image into the Android project's res/drawable directory.

However, it doesn't tell mew what to name the files, and is unclear how to implement them. What I do have are directories named drawable-mdpi, drawable-ldpi, drawable-hdpi, and drawable-xhpdi, I tried placing a splash.png file with the right dimensions in each of them.

Problem 2: When I build the .APK file, and test it on my phone, what I get is a default screen with a black bar at the top that contains the name of my app. This screen seems to be generated from a file called /res/layout/activity_main.xml:

default layout

How do I remove this default layout and get my own splash screens to display?

Note: Based on information in this answer, have this code in my MainActivity.java:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    super.loadUrl(Config.getStartUrl(), 2000);
    super.loadUrl("file:///android_asset/www/index.html");

    adView = new AdView(this, AdSize.BANNER, AdMob_Ad_Unit);
    LinearLayout layout = super.root;
    layout.addView(adView);
    AdRequest request = new AdRequest();
    adView.loadAd(request); 
}

Unfortunately, it has not changed anything.


Update: I'mnot sure exactly what has changed, but right now my splash screen does seem to show, but I'm still getting this default screen with the black bar at top flickering and appearing before my splash screen. How do I kill this screen from appearing?

Community
  • 1
  • 1
Questioner
  • 7,133
  • 16
  • 61
  • 94
  • check this : http://stackoverflow.com/questions/8156841/phonegap-splash-screen-for-android-app – dreamcoder Aug 27 '13 at 03:53
  • @dreamcoder: Thanks for that link. I actually had already implemented the code there, but failed to mention it in my question. I've updated my question to repair my omission. – Questioner Aug 27 '13 at 04:00
  • Post the code of onCreate of your MainActivity.java – Rajesh Aug 27 '13 at 04:08
  • @Rajesh: Thanks for responding. I've added the entirety of my `onCreate` method to my question. – Questioner Aug 27 '13 at 04:10
  • You seem to be calling the loadUrl twice. Remove the 2nd one. – Rajesh Aug 27 '13 at 04:23
  • @Rajesh: Thank you for the suggestion. I removed the second `loadUrl` line, but I am still getting the default screen showing up before my splash screen. – Questioner Aug 27 '13 at 04:43
  • This is a general suggestion, not specific to phonegap - adding `android:theme="@android:style/Theme.NoTitleBar"` to the `application` tag in your AndroidManifest.xml should remove the title bar from the screens in your app. – Rajesh Aug 27 '13 at 04:53
  • @Rajesh: Replacing the `android:theme` line in my `AndroidManifest.xml` as you usggested seems to have solved the problem. If you put your advice into an answer, I'll mark it as correct. Thanks! – Questioner Aug 27 '13 at 05:09

1 Answers1

3
  1. Call loadUrl only once. This call should be the one where you call it with a delay parameter, if you want to show the splash.
  2. In the AndroidManifest.xml, if you make the android:theme="@android:style/Theme.NoTitleBar", it should remove the title bar from all the screens in your app. The splash screen plugin seems to be doing it only for the splash screen, but your requirement seems to be for the entire app.
Rajesh
  • 15,724
  • 7
  • 46
  • 95