IBM工作灯5.0.6 - 如何添加一个启动画面到Android环境?画面、环境、工作灯、IBM

2023-09-04 04:07:12 作者:鮟嘫

我现在面临的一个问题,而试图添加启动screenin的Andr​​oid。 下面是code我用

I am facing an issue while trying to add a splash screenin Android. Below is the code I used

public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    super.setIntegerProperty("splashscreen", R.drawable.splash);
    super.bindBrowser(appView);
    super.loadUrl(getWebMainFilePath(), 5000);
}

我看到开机画面,但几分钟后,我得到了一个空白屏幕和应用程序崩溃。

I see the splash image, but then after few minutes I get a blank screen and the app crashes.

推荐答案

在使用工作灯,可以显示onWLInitCompleted方法闪屏和方法保留的onCreate为默认值。 下面就的Nexus 4,的Andr​​iod 4.2.2。code测试

When using Worklight, you can show splash screen in onWLInitCompleted method and leave onCreate method as default. Below code test on Nexus 4, Andriod 4.2.2.

@Override
public void onWLInitCompleted(Bundle savedInstanceState) {
    // set splash screen image
    super.setIntegerProperty("splashscreen", R.drawable.logo_image);
    // Set skin name to skip load skinLoader.html if you have no customized skin.
    // This will fix the splash screen flicker on some Android devices when the App first time running.
    WLUtils.writeWLPref(getContext(), "wlSkinName", "default");
    WLUtils.writeWLPref(getContext(), "exitOnSkinLoader", "true");
    // show splash screen 3 seconds
    super.loadUrl(getWebMainFilePath(), 3000);
}