有一个链接,它会在5秒钟内重定向到另一页,如何在重定向之前进行延迟?以下是一个示例链接:http://s.spynetstation.com/m/Logistics/Logistics%20-%20Medical%20History%20NHSDL09,%202007/05%20Logistics%20-%20Safe%20On%20My%20Side.mp3。
代码:
public void ShowTrack(String smetaout,String stitleout){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle(stitleout);
WebView wv = new WebView(this);
wv.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
Log.d("My Webview", "shouldOverrideUrlLoading"+urlNewString);
if (!loadingFinished) {
redirect = true;
}
loadingFinished = false;
view.loadUrl(urlNewString);
Log.d("My Webview", urlNewString);
return false;
}
public void onPageStarted(WebView view, String url) {
Log.d("My Webview", "onPageStarted"+url);
loadingFinished = false;
}
@Override
public void onPageFinished(WebView view, String url) {
if(!redirect){
loadingFinished = true;
}
if(loadingFinished && !redirect){
} else{
redirect = false;
}
Log.d("My Webview", "onPageFinished"+url);
}
});
wv.loadUrl(smetaout);
alert.setView(wv);
alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
alert.show();
}