Merge branch 'master' into master
This commit is contained in:
commit
811160c73f
@ -15,10 +15,10 @@ If you want to create an app that displays the content of a remote website
|
|||||||
mWebView.setWebViewClient(new MyWebViewClient());
|
mWebView.setWebViewClient(new MyWebViewClient());
|
||||||
```
|
```
|
||||||
|
|
||||||
2. open the `MyWebViewClient.java` file and replace `example.com` on line **12** with your custom hostname
|
2. open the `MyWebViewClient.java` file and replace `example.com` on line **15** with your custom hostname
|
||||||
|
|
||||||
```java
|
```java
|
||||||
if (Uri.parse(url).getHost().endsWith("example.com")) {
|
if (Objects.requireNonNull(Uri.parse(url).getHost()).endsWith("example.com")) {
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using a local source
|
### Using a local source
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 25
|
compileSdkVersion 28
|
||||||
buildToolsVersion '27.0.3'
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.example.app"
|
applicationId "com.example.app"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 25
|
targetSdkVersion 28
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.example.app;
|
package com.example.app;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
@ -12,12 +11,13 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
private WebView mWebView;
|
private WebView mWebView;
|
||||||
|
|
||||||
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
mWebView = (WebView) findViewById(R.id.activity_main_webview);
|
mWebView = findViewById(R.id.activity_main_webview);
|
||||||
|
|
||||||
// Force links and redirects to open in the WebView instead of in a browser
|
// Force links and redirects to open in the WebView instead of in a browser
|
||||||
mWebView.setWebViewClient(new WebViewClient());
|
mWebView.setWebViewClient(new WebViewClient());
|
||||||
|
@ -5,8 +5,11 @@ import android.net.Uri;
|
|||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
|
|
||||||
public class MyWebViewClient extends WebViewClient {
|
import java.util.Objects;
|
||||||
|
|
||||||
|
class MyWebViewClient extends WebViewClient {
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||||
Uri uri = Uri.parse(url);
|
Uri uri = Uri.parse(url);
|
||||||
|
@ -6,7 +6,7 @@ buildscript {
|
|||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.2.1'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Mon Oct 29 15:19:59 CET 2018
|
#Mon Jan 21 19:31:21 CET 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
||||||
|
Loading…
Reference in New Issue
Block a user