2012-07-20 20 views
1

任何人都可以告訴我如何在默認webview中打開一個URL。我正在使用下面的代碼,但它不工作。它仍然在提示選擇意圖。這段代碼在我的三星S2智能手機中工作正常。但不在Galaxy平板電腦中。如何在webview中打開URL而不提示在Android中使用瀏覽器選擇Honeycomb

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."); 
     }    
    } 
} 
+0

變量'browser'是'WebView' rt的一個實例嗎? – sunil 2012-07-20 04:59:03

+0

是的。這是webview。蜂窩行爲是不同的? – Harish 2012-07-21 17:22:12

回答

2

你不能直接,直到除非你知道你想要觸發瀏覽應用程序,這不是一個好主意,反正的活動名稱。

將選項留給用戶,或者您可以在應用程序中實現您自己的瀏覽器(如模塊),並將用戶直接帶到您應用程序的瀏覽器。

+0

但問題作者已經使用'WebView' rt?他正在嘗試在webview本身內部加載url。 – sunil 2012-07-20 04:57:49

相關問題