[英]IBM Worklight 5.0.6 - How to add a splash screen to Android environment?
嘗試在Android中添加啟動畫面時,我遇到了一個問題。
以下是我使用的代碼
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.bindBrowser(appView);
super.loadUrl(getWebMainFilePath(), 5000);
}
我看到啟動圖像,但幾分鍾后我得到一個空白屏幕,應用程序崩潰。
使用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);
}
我不知道它會幫助你或者只是嘗試使用這個代碼...
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);
希望它有效..
我在onCreate
做你做的事情,但加載這樣的URL:
public void onWLInitCompleted(Bundle savedInstanceState){
super.loadUrl(getWebMainFilePath(), 5000);
}
適合我(在Nexus 7,Android 4.2.2上測試)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.