My name is Heath Anderson.
This is my website.

Adding a Splash Screen For An Android PhoneGap App

The fact that you can add a splash screen to your PhoneGap app on the Android platform is surprisingly hard to come across. After some searching I did find some answers.

After finding those helpful posts my next question was:

What is this property thing I'm setting?

Starting on line 100 of the DroidGap.java file there are some helpful comments:


/* Properties: The application can be configured using the following properties:
*
*    // Display a native loading dialog.  Format for value = "Title,Message".
*    // (String - default=null)
*    super.setStringProperty("loadingDialog", "Wait,Loading Demo...");
*
*    // Hide loadingDialog when page loaded instead of when deviceready event
*    // occurs. (Boolean - default=false)
*    super.setBooleanProperty("hideLoadingDialogOnPage", true);
*
*    // Cause all links on web page to be loaded into existing web view,
*    // instead of being loaded into new browser. (Boolean - default=false)
*    super.setBooleanProperty("loadInWebView", true);
*
*    // Load a splash screen image from the resource drawable directory.
*    // (Integer - default=0)
*    super.setIntegerProperty("splashscreen", R.drawable.splash);
*
*    // Time in msec to wait before triggering a timeout error when loading
*    // with super.loadUrl().  (Integer - default=20000)
*    super.setIntegerProperty("loadUrlTimeoutValue", 60000);
*
*    // URL to load if there's an error loading specified URL with loadUrl().
*    // Should be a local URL starting with file://. (String - default=null)
*    super.setStringProperty("errorUrl", "file:///android_asset/www/error.html");
*
*    // Enable app to keep running in background. (Boolean - default=true)
*    super.setBooleanProperty("keepRunning", false);
*/

These properties can be set in your appname.java file:


package com.example.appname;
import android.app.Activity;
import android.os.Bundle;
import com.phonegap.*;
public class appname extends DroidGap
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html", 3000);
}
}