2012-01-18 45 views
0

我想爲現有網站創建迷你瀏覽器。 我使用下面的代碼:適用於Android的瀏覽器

WebView webview = new WebView(this); 
    setContentView(webview); 
    webview.loadUrl("http://my_url"); 

在應用程序中打開頁面星期三,但接下來的網頁鏈接在非標準Android的瀏覽器中打開。 如何確保在應用程序中打開的網頁不是Android瀏覽器?

+0

[Nice教程爲您的問題。](http://marakana.com/forums/android/examples/58.html) – 2012-01-18 15:06:08

回答

2

使用這個在你的代碼..

WebView.setWebViewClient(new WebViewClient()); 

應該這樣做,所以現在所有點擊打開鏈接在瀏覽器中

0

梅比你可以設置一個IntentFilter的爲您的活動像這樣

<intent-filter> 
    <action android:name="android.intent.action.VIEW"/> 
    <category android:name="android.intent.category.DEFAULT"/> 
    <category android:name="android.intent.category.BROWSABLE"/> 
    <data android:scheme="http"/> 
</intent-filter> 

因此,任何時候打開鏈接都會被要求將您的應用用作瀏覽器。

我希望這可以幫助你。

+0

正確的方法去這個是我上面提供的方法。 =)雖然想法很好。 – 2012-01-18 16:06:49

相關問題