minor fixes
This commit is contained in:
parent
5c5fc4656c
commit
b2f9d68d09
@ -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,11 +5,13 @@ 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 {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user