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
b2f9d68d
Commit
b2f9d68d
authored
Jan 21, 2019
by
slymax
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor fixes
parent
5c5fc465
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
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
-2
No files found.
app/src/main/java/com/example/app/MainActivity.java
View file @
b2f9d68d
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 @
b2f9d68d
...
...
@@ -5,11 +5,13 @@ 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
{
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
if
(
Uri
.
parse
(
url
).
getHost
(
).
endsWith
(
"example.com"
))
{
if
(
Objects
.
requireNonNull
(
Uri
.
parse
(
url
).
getHost
()
).
endsWith
(
"example.com"
))
{
return
false
;
}
...
...
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