1. Are you ready for the Galaxy S20? Here is everything we know so far!

I want the web page open inside app not OUTSIDE HOW

Discussion in 'Android Development' started by giannis97, Feb 10, 2019.

  1. giannis97

    giannis97 Newbie
    Thread Starter

    I found an app's source code and the first page when you open the app, it opens the page from gooogle chrome or any other browser but I want when someone open the app to open specific page, it should open in the app not external . I think this below I should change somehow

    private class MyWebviewClient extends WebViewClient {
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
    if (Uri.parse(url).getHost().equals("http://dmc.teiion.gr")) {
    //open url contents in webview
    return false;
    } else {
    //here open external links in external browser or app
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    return true;

    1. Download the Forums for Android™ app!


  2. GameTheory

    GameTheory Android Expert


    The following class opens links within your own app instead of the default browser.

    Code (Java):
    1. private class MyWebViewClient extends WebViewClient {
    2.     @Override
    3.     public boolean shouldOverrideUrlLoading(WebView view, String url) {
    4.         return super.shouldOverrideUrlLoading(view, url);
    5.     }
    6. }
    There's a full tutorial and complete project in the following link. Read the comments in the code which will tell you what everything does.


Share This Page