谁能告诉我如何在默认Web视图中打开URL吗。我正在使用以下代码,但它不起作用。它仍在提示选择意图。这个代码在我的三星S2智能手机中运行良好。但Galaxy平板电脑没有。
browser.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//check for key strings in URL to determine next action.
int useNativeIntent = 0;
int bolDone = 0;
//allow loading of this URL
if(useNativeIntent == 0){
showProgress("Loading..","This may take a moment if you have a slow internet connection.");
loadBrowser(url);
}
return true;
}
//loadBrowser
public void loadBrowser(String theUrl){
if(browser != null){
try{
browser.loadUrl(theUrl);
}catch(Exception je){
hideProgress();
showAlert("Error Loading?","There was a problem loading some data. Please check your internet connection then try again.");
}
}
}
除非知道要触发的浏览器应用程序的活动名称,否则不能直接触发,这无论如何都不是一个好主意。
将选项留给用户,或者您可以在应用程序中实现自己的类似浏览器的模块,并将用户直接带到应用程序的浏览器。