Web ページを数秒間表示してから、別のアクティビティを開始する必要があります。私がやっているのは onResume() メソッドで、Thread.sleep() を呼び出してから新しいアクティビティを開始しますが、実行すると Web ページが表示されません。黒い画面を表示し、次のアクティビティを実行します。私は何が間違っているのでしょうか?これが私のコードです:
public class ShowPortalActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String url = "http://someurl.com";
WebView webview = (WebView) findViewById(R.id.webView);
// next line explained below
webview.setWebViewClient(new WebViewClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl(url);
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
try {
newActivity();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void newActivity() throws InterruptedException {
Thread.sleep(3000);
Intent intent = new Intent(ShowPortalActivity.this, Inicio.class);
startActivity(intent);
}
}