Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Load an external web site in a WebView on SSaurel's Blog
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