Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created October 2, 2017 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/b8db2feb8383c27bc48ac0bbe9a0793e to your computer and use it in GitHub Desktop.
Save ssaurel/b8db2feb8383c27bc48ac0bbe9a0793e to your computer and use it in GitHub Desktop.
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