From 8e7a8d781146496714d8f8c8d7ecda68e131ea32 Mon Sep 17 00:00:00 2001 From: slymax Date: Mon, 13 Apr 2020 10:00:01 +0200 Subject: [PATCH] simplify config --- README.md | 4 ++-- app/src/main/java/com/example/app/MyWebViewClient.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae16a29..d60c6f9 100755 --- a/README.md +++ b/README.md @@ -8,13 +8,13 @@ This is a template project for Android Studio that allows you to create an andro If you want to create an app that shows the content of a remote website -1. uncomment line **24** in `MainActivity.java` and replace `https://example.com` with your remote source +1. uncomment line **24** in `MainActivity.java` and replace `https://example.com` with your url ```java mWebView.loadUrl("https://example.com"); ``` -2. open the `MyWebViewClient.java` file and replace `example.com` on line **13** with your hostname +2. open the `MyWebViewClient.java` file and replace `example.com` on line **15** with your hostname ```java hostname = "example.com"; diff --git a/app/src/main/java/com/example/app/MyWebViewClient.java b/app/src/main/java/com/example/app/MyWebViewClient.java index 8f6c392..c9f7178 100755 --- a/app/src/main/java/com/example/app/MyWebViewClient.java +++ b/app/src/main/java/com/example/app/MyWebViewClient.java @@ -10,7 +10,10 @@ class MyWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { String hostname; + + // YOUR HOSTNAME hostname = "example.com"; + Uri uri = Uri.parse(url); if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) { return false;