想问一下,如果webview加载的时间太长,有没有办法在Android中杀死/移动到另一个活动,例如5秒。
答案 0 :(得分:0)
你可以使用
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if(isStillLoading())
//move to the next activity
}
},3000);
你必须使用方法isStillLoading
答案 1 :(得分:0)
您可以使用WebClient
-
private boolean loadingFinished;
mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
return false;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap facIcon) {
loadingFinished = false;
//SHOW LOADING IF IT ISNT ALREADY VISIBLE
}
@Override
public void onPageFinished(WebView view, String url) {
loadingFinished = true;
}
});
用户Handler
检查5秒后是否加载webview
-
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// Will get executed after 5 seconds
if(!loadingFinished)
//move to the next activity
}
},5000); //5000 miliseconds.. i.e. 5 seconds