Skip to content

Commit

Permalink
simplify config
Browse files Browse the repository at this point in the history
  • Loading branch information
slymax committed Mar 29, 2020
1 parent 8c64844 commit 717d7e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ This is a template project for Android Studio that allows you to create an andro

### Using a remote source

If you want to create an app that displays the content of a remote website
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

```java
mWebView.loadUrl("https://example.com");
```

2. open the `MyWebViewClient.java` file and replace `example.com` on line **13** with your custom hostname
2. open the `MyWebViewClient.java` file and replace `example.com` on line **13** with your hostname

```java
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith("example.com")) {
hostname = "example.com";
```

### Using a local source
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/com/example/app/MyWebViewClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class MyWebViewClient extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
String hostname;
hostname = "example.com";
Uri uri = Uri.parse(url);
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith("example.com")) {
if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
Expand Down

0 comments on commit 717d7e8

Please sign in to comment.