• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps I want the web page open inside app not OUTSIDE HOW

giannis97

Newbie
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 {
@override
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));
startActivity(intent);
return true;
}
 
@giannis97

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

Java:
private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return super.shouldOverrideUrlLoading(view, url);
    }
}

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.

https://intechgeek.com/android-webview/
 
Back
Top Bottom