My Fragment
inside a FragmentPagerAdapter
contains several WebViews
stored in a HashMap
. I'm trying to stop them reloading when I rotate the device. I've tried several things but none of them work. This is what I'm currently trying but still no joy.
My webViews
HashMap
is also being wiped on rotate. Will making it static
fix that?
Latest attempt.. After rotation webViewBundle appears to be null.
Relevant Code:
public class SfnViewerFragment extends Fragment {
private WebView webView;
private View rootView;
private HashMap<Long, WebView> webViews = new HashMap<Long, WebView>();
private static Bundle webViewBundle;
@Override
public void onPause() {
super.onPause();
webViewBundle = new Bundle();
if (webView != null) {
webView.saveState(webViewBundle);
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (webViewBundle != null) {
webView.restoreState(webViewBundle);
}
}
I also had this in my manifest but it still didn't help:
android:configChanges="orientation"