Skip to content

Instantly share code, notes, and snippets.

@nickstewart95
Created March 23, 2017 13:35
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 nickstewart95/b84bf36a57d766c75fcf9efd4508d6f3 to your computer and use it in GitHub Desktop.
Save nickstewart95/b84bf36a57d766c75fcf9efd4508d6f3 to your computer and use it in GitHub Desktop.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//hide statusbar
if (Build.VERSION.SDK_INT < 16) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
} else {
setContentView(R.layout.activity_main);
android.support.v7.app.ActionBar ab = getSupportActionBar();
ab.hide();
}
//setup our webview
WebView myWebView = (WebView) findViewById(R.id.webView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setBuiltInZoomControls(false);
webSettings.setDomStorageEnabled(true);
webSettings.setDatabaseEnabled(true);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
webSettings.setDatabasePath("/data/data/" + myWebView.getContext().getPackageName() + "/databases/");
}
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
myWebView.setBackgroundColor(Color.parseColor("#147F52"));
myWebView.loadUrl("file:///android_asset/index.html");
}
@Override
public void onBackPressed() {
WebView myWebView = (WebView) findViewById(R.id.webView);
if (myWebView.canGoBack()) {
myWebView.goBack();
} else {
super.onBackPressed();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment