如何在Webview中打开URL而不提示Android Honeycomb中的浏览器选择

时间:2012-07-20 04:28:48

标签: android android-3.0-honeycomb

任何人都可以告诉我如何在默认的webview中打开一个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.");
        }               
    }
}

1 个答案:

答案 0 :(得分:2)

除非您知道要触发的浏览器应用的活动名称,否则您无法直接使用,这无论如何都不是一个好主意。

将选项留给用户,或者您可以在应用内部实现自己的浏览器模块,并将用户直接带到应用的浏览器。