[英]IBM Worklight 5.0.6 - How to add a splash screen to Android environment?
I am facing an issue while trying to add a splash screenin Android. 尝试在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. 我看到启动图像,但几分钟后我得到一个空白屏幕,应用程序崩溃。
When using Worklight, you can show splash screen in onWLInitCompleted method and leave onCreate method as default. 使用Worklight时,可以在onWLInitCompleted方法中显示启动画面,并将onCreate方法保留为默认值。
Below code test on Nexus 4, Andriod 4.2.2. 下面是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);
}
I dont know will it help you or not but just try to use this code... 我不知道它会帮助你或者只是尝试使用这个代码...
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);
Hope it works.. 希望它有效..
I do what you do in onCreate
, but load the URL like this: 我在
onCreate
做你做的事情,但加载这样的URL:
public void onWLInitCompleted(Bundle savedInstanceState){
super.loadUrl(getWebMainFilePath(), 5000);
}
Works for me (testing on Nexus 7, Android 4.2.2). 适合我(在Nexus 7,Android 4.2.2上测试)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.