Created
October 2, 2017 13:02
-
-
Save ssaurel/b8db2feb8383c27bc48ac0bbe9a0793e to your computer and use it in GitHub Desktop.
Load an external web site in a WebView on SSaurel's Blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ssaurel.webview; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import android.webkit.WebView; | |
import android.webkit.WebViewClient; | |
public class MainActivity extends AppCompatActivity { | |
private WebView webView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
webView = new WebView(this); | |
webView.getSettings().setJavaScriptEnabled(true); | |
webView.setWebViewClient(new WebViewClient()); | |
webView.loadUrl("https://www.ssaurel.com/blog"); | |
setContentView(webView); | |
} | |
@Override | |
protected void onDestroy(){ | |
super.onDestroy(); | |
if (webView != null) { | |
webView.destroy(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment