Question Detail

create a webview in which a web page work properly . I creating a webview in which a web page is open but when i click on any link on the web page it want to select browser and i want to resume browsing that page in the same app.

xml:

<WebView
    android:id="@+id/web_id"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

 

javafile:

public class Techximum extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_techximum);
        WebView mywebview = (WebView)findViewById(R.id.web_id);
        mywebview.loadUrl("https://www.google.com");
    }
}


Thread Reply

- 6 months ago

When we click on any link on website default behaviour of WebView is open link on Default browser. To handle these type of Navigation,

so we need to change its behaviour accordingly 

simply provide a WebViewClient for your WebView, using setWebViewClient()

Just implement the web client and set it before loadUrl.

The simplest way is:

mywebview.setWebViewClient(new WebViewClient());

For more advanced processing for the web content, consider the ChromeClient.