I am using Worklight for an Android application,
When I try to add a splash screen
public class MyApp extends WLDroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(getWebMainFilePath(),2000);
}
}
I see the splash screen, but then, I have a black screen and the app crashes to be accurate, it shows a black screen, and when I tap on options button, it crashes
When I remove the ",2000"
public class MyApp extends WLDroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(getWebMainFilePath());
}
}
I don't see the splash screen, and the app works.
I see that someone talked about that in IBM forums
And there are many blog posts talking about splashsccreens for Android with PhoneGap here and here, but I dont see a solution in these posts to my problem
Here are the app log after the crash:
I/SurfaceFlinger( 93): [SurfaceFlinger] frames:2, duration:2.262000, fps:0.883908
I/InputDispatcher( 246): channel '426b7be0 NavigationBar (server)' ~ finishDispatchCycle - 4.8ms since event, 3.0ms since dispatch, handled=true
E/AndroidRuntime(15615): FATAL EXCEPTION: main
E/AndroidRuntime(15615): java.lang.NullPointerException
E/AndroidRuntime(15615): at com.worklight.androidgap.WLDroidGap.onPrepareOptionsMenu(WLDroidGap.java:163)
E/AndroidRuntime(15615): at com.worklight.androidgap.WLDroidGap.onCreateOptionsMenu(WLDroidGap.java:159)
E/AndroidRuntime(15615): at android.app.Activity.onCreatePanelMenu(Activity.java:2458)
E/AndroidRuntime(15615): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:389)
E/AndroidRuntime(15615): at com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel(PhoneWindow.java:770)
E/AndroidRuntime(15615): at com.android.internal.policy.impl.PhoneWindow.onKeyDown(PhoneWindow.java:1435)
E/AndroidRuntime(15615): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1824)
E/AndroidRuntime(15615): at android.view.ViewRootImpl.deliverKeyEventPostIme(ViewRootImpl.java:3492)
E/AndroidRuntime(15615): at android.view.ViewRootImpl.handleFinishedEvent(ViewRootImpl.java:3464)
E/AndroidRuntime(15615): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2601)
E/AndroidRuntime(15615): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(15615): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(15615): at android.app.ActivityThread.main(ActivityThread.java:4524)
E/AndroidRuntime(15615): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(15615): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(15615): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
E/AndroidRuntime(15615): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
E/AndroidRuntime(15615): at dalvik.system.NativeStart.main(Native Method)
Go to app > java > first package name > right-click > New > Activity > Empty Activity and create another activity and named it as SplashScreen. Edit the activity_splash_screen. xml file and add image, text in the splash screen as per the requirement. Here we are adding an image to the splash screen.
Starting in Android 12, the launch animation for all apps when running on a device with Android 12 or higher. This includes an into-app motion at launch, a splash screen showing your app icon, and a transition to your app itself.
If you are on Worklight 5.0.5.x try this:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl(getWebMainFilePath()); // yes, this is an extra invocation
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(getWebMainFilePath(), 5000);
}
If you are on Worklight 5.0.6.x try this:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.bindBrowser(appView);
super.loadUrl(getWebMainFilePath(), 5000);
}
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