Android上的Worklight App Splash Screen
作者:互联网
我正在将Worklight用于Android应用程序,
当我尝试添加启动画面时
public class MyApp extends WLDroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(getWebMainFilePath(),2000);
}
}
我看到了启动画面,但是,我有一个黑屏,应用程序崩溃了
准确地说,它显示黑屏,当我点击选项按钮时,它会崩溃
当我删除“,2000”
public class MyApp extends WLDroidGap {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl(getWebMainFilePath());
}
}
我没有看到启动画面,应用程序正常工作.
我看到有人talked about that in IBM forums
有很多博客文章都在谈论Android的带有PhoneGap的splashsccreens
here和here,但我没有在这些帖子中看到我的问题的解决方案
以下是崩溃后的应用程序日志:
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)
解决方法:
如果您使用的是Worklight 5.0.5.x,请尝试以下操作:
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);
}
如果您使用的是Worklight 5.0.6.x,请尝试以下操作:
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.bindBrowser(appView);
super.loadUrl(getWebMainFilePath(), 5000);
}
标签:android,splash-screen,cordova,ibm-mobilefirst 来源: https://codeday.me/bug/20190517/1122844.html