我打开设备浏览器到意图中的特定网址,如下所示:
String url = "http://www.google.com";
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
我现在如何验证页面是否已在浏览器中成功加载?有没有办法返回浏览器应用程序的加载状态或内容?
答案 0 :(得分:0)
你可以试试这个
try
{
String url = "http://www.google.com";
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
希望有所帮助
答案 1 :(得分:0)
您可以使用方法WebViewClient
或onPageFinished()
来实现onReceivedError()
:
myWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
Log.i("WebView", "Page succesfully loaded!");
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
Log.e("WebView", "An error ocurred: " + description + " loading the page:" + failingUrl + ", with code" + errorCode); }
});
有关可能的错误代码的Mor信息: http://developer.android.com/reference/android/webkit/WebViewClient.html#Summary
更多信息:
<强> WebViewClient 强>