IBM Worklight 5.0.6 - 如何在Android环境中添加启动画面?

时间:2013-04-16 04:43:21

标签: android splash-screen ibm-mobilefirst

我在尝试在Android中添加启动画面时遇到问题 以下是我使用的代码

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

我看到启动图像,但几分钟后我得到一个空白屏幕,应用程序崩溃。

3 个答案:

答案 0 :(得分:2)

使用Worklight时,您可以在onWLInitCompleted方法中显示启动画面,并将onCreate方法保留为默认值。
下面是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);
}

答案 1 :(得分:0)

我不知道它会对你有所帮助,但只是尝试使用这段代码......

setContentView(R.layout.splashscreen);
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        public void run() {
            // TODO Auto-generated method stub
            finish();
            Intent menu = new Intent(getBaseContext(), MainMenu.class);
            startActivity(menu);
        }
    }, 3000);

希望它有效..

答案 2 :(得分:0)

我会在onCreate中执行您的操作,但会加载以下网址:

public void onWLInitCompleted(Bundle savedInstanceState){
    super.loadUrl(getWebMainFilePath(), 5000);
}

适合我(在Nexus 7,Android 4.2.2上测试)。