When I rotate my devices, this charge again his class. For example, if I have a google search when I change the orientation charges again to google.
I’ve try it with:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setContentView(R.layout.principal);
}
and onRestoreInstanceState and onSaveInstanceState. But my problem persist. I would appreciate if somebody can help me with a example or explication of how can to do it.
Thank’s!
I’ve solved the problem, I needed to do the if (savedInstanceState == null) :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.principal);
webview.setWebViewClient(new WebViewClient());
if (savedInstanceState == null)
{
webview.loadUrl("http://www.apple.es");
}
}
@Override
protected void onSaveInstanceState(Bundle outState)
{
super.onSaveInstanceState(outState);
// Save the state of the WebView
webview.saveState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState)
{
super.onRestoreInstanceState(savedInstanceState);
// Restore the state of the WebView
webview.restoreState(savedInstanceState);
}
I hope than my problem and my solution can help to somebody!
Christian you have to see this doc on android developer web site and learn how romain guy stores his last loaded image and call them when the configuration screen changes!! the solution is to use
I also refer to this tutorial always to get rid of the screen change behavour of android
hope this will help you