I\'ve been working on an application which have a WebView in which a static page get loaded from the assets (Also using JavaScript). This WebView is not working in KitKat, i
package com.example.testandroid;
public class MainActivity extends ActionBarActivity {
WebView webView=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (savedInstanceState != null)
{
((WebView)findViewById(R.id.web_view)).restoreState(savedInstanceState);
}
else{
webView=(WebView)findViewById(R.id.web_view);
webView.loadUrl("http://www.google.co.in");
webView.getSettings().getJavaScriptEnabled();
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view,
String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
});
}
}
protected void onSaveInstanceState(Bundle outState) {
webView.saveState(outState);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack();
return true;
}
// If it wasn't the Back key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}
}