minor fixes
This commit is contained in:
parent
66d545e734
commit
1582de593e
@ -16,25 +16,19 @@ public class MainActivity extends Activity {
|
|||||||
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 = 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());
|
mWebView.setWebViewClient(new WebViewClient());
|
||||||
|
|
||||||
// Enable Javascript
|
|
||||||
WebSettings webSettings = mWebView.getSettings();
|
WebSettings webSettings = mWebView.getSettings();
|
||||||
webSettings.setJavaScriptEnabled(true);
|
webSettings.setJavaScriptEnabled(true);
|
||||||
|
|
||||||
// REMOTE RESOURCE
|
// REMOTE RESOURCE
|
||||||
// mWebView.loadUrl("http://example.com");
|
// mWebView.loadUrl("https://example.com");
|
||||||
// mWebView.setWebViewClient(new MyWebViewClient());
|
// mWebView.setWebViewClient(new MyWebViewClient());
|
||||||
|
|
||||||
// LOCAL RESOURCE
|
// LOCAL RESOURCE
|
||||||
// mWebView.loadUrl("file:///android_asset/index.html");
|
// mWebView.loadUrl("file:///android_asset/index.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent the back-button from closing the app
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if(mWebView.canGoBack()) {
|
if(mWebView.canGoBack()) {
|
||||||
@ -43,5 +37,4 @@ public class MainActivity extends Activity {
|
|||||||
super.onBackPressed();
|
super.onBackPressed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@ -7,7 +7,6 @@ import android.webkit.WebViewClient;
|
|||||||
|
|
||||||
class MyWebViewClient extends WebViewClient {
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user