I have a simple webView app which loads a page from our site with locations and phone numbers that our field guys are supposed to visit each day. It provides a hook to launch navigation or dial the phone. When returning from the outside activity, the app is crashing. Hitting the phone's home button then dialing the phone, then returning to the app works fine.
here's the code...
Update 2 - No longer crashing, webview is blank upon returning
public class VSIMobile_WebView extends Activity {
private static String PROVIDER="gps";
private WebView browser;
private LocationManager myLocationManager=null;
private TelephonyManager myTeleManager = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
browser=(WebView)findViewById(R.id.webview);
myLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
myTeleManager=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
browser.getSettings().setJavaScriptEnabled(true);
browser.addJavascriptInterface(new Locater(), "locater");
browser.addJavascriptInterface(new JavaScriptInterface(this), "Android");
if (savedInstanceState!=null){
browser.restoreState(savedInstanceState);
}else{
browser.loadUrl("http://zzz.com");
browser.setWebViewClient(new HelloWebViewClient());
}
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
public void onSaveInstanceState(Bundle outState) {
//Toast.makeText(getBaseContext(), browser.getUrl(), Toast.LENGTH_LONG).show();
browser.saveState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle state) {
browser.restoreState(state);
super.onRestoreInstanceState(state);
//Toast.makeText(getBaseContext(), browser.getUrl(), Toast.LENGTH_LONG).show();
}
/* Did not work
public void onResume(Bundle inState){
browser.restoreState(inState);
super.onResume();
}
public void onPause(Bundle outState) {
browser.saveState(outState);
super.onPause();
}
*/
@Override
public void onResume(){
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}