Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webview
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
webview
Commits
811160c7
Unverified
Commit
811160c7
authored
Feb 16, 2019
by
Max
Committed by
GitHub
Feb 16, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
0fe0748d
37ec2568
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
12 deletions
+14
-12
README.md
README.md
+2
-2
build.gradle
app/build.gradle
+2
-3
MainActivity.java
app/src/main/java/com/example/app/MainActivity.java
+3
-3
MyWebViewClient.java
app/src/main/java/com/example/app/MyWebViewClient.java
+4
-1
build.gradle
build.gradle
+1
-1
gradle-wrapper.properties
gradle/wrapper/gradle-wrapper.properties
+2
-2
No files found.
README.md
View file @
811160c7
...
...
@@ -15,10 +15,10 @@ If you want to create an app that displays the content of a remote website
mWebView.setWebViewClient(new MyWebViewClient());
```
2.
open the
`MyWebViewClient.java`
file and replace
`example.com`
on line
**1
2
**
with your custom hostname
2.
open the
`MyWebViewClient.java`
file and replace
`example.com`
on line
**1
5
**
with your custom hostname
```java
if (
Uri.parse(url).getHost(
).endsWith("example.com")) {
if (
Objects.requireNonNull(Uri.parse(url).getHost()
).endsWith("example.com")) {
```
### Using a local source
...
...
app/build.gradle
View file @
811160c7
apply
plugin:
'com.android.application'
android
{
compileSdkVersion
25
buildToolsVersion
'27.0.3'
compileSdkVersion
28
defaultConfig
{
applicationId
"com.example.app"
minSdkVersion
21
targetSdkVersion
2
5
targetSdkVersion
2
8
versionCode
1
versionName
"1.0"
}
...
...
app/src/main/java/com/example/app/MainActivity.java
View file @
811160c7
package
com
.
example
.
app
;
import
android.annotation.SuppressLint
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
...
...
@@ -12,12 +11,13 @@ public class MainActivity extends Activity {
private
WebView
mWebView
;
@SuppressLint
(
"SetJavaScriptEnabled"
)
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
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
mWebView
.
setWebViewClient
(
new
WebViewClient
());
...
...
app/src/main/java/com/example/app/MyWebViewClient.java
View file @
811160c7
...
...
@@ -5,8 +5,11 @@ import android.net.Uri;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
public
class
MyWebViewClient
extends
WebViewClient
{
import
java.util.Objects
;
class
MyWebViewClient
extends
WebViewClient
{
@SuppressWarnings
(
"deprecation"
)
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
Uri
uri
=
Uri
.
parse
(
url
);
...
...
build.gradle
View file @
811160c7
...
...
@@ -6,7 +6,7 @@ buildscript {
google
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:3.
2.1
'
classpath
'com.android.tools.build:gradle:3.
3.0
'
}
}
...
...
gradle/wrapper/gradle-wrapper.properties
View file @
811160c7
#Mon
Oct 29 15:19:59 CET 2018
#Mon
Jan 21 19:31:21 CET 2019
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment