Answer the question
In order to leave comments, you need to log in
WebView - how not to reload the page when the screen is rotated?
Given: an application with one host Activity and many Fragments. In one of the fragments, the content is loaded into the WebView. I would like to make sure that the page does not reload from the web every time the user rotates the device.
Stackoverflow offers this answer:
public class MyFragment extends Fragment {
...
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
if (savedInstanceState == null) {
mWebView.loadUrl(URL);
} else {
mWebView.restoreState(savedInstanceState);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
mWebView.saveState(outState);
}
}
Answer the question
In order to leave comments, you need to log in
Склонен считать, что это проблема мобильного хромиума (который и есть вебвью)
типа такой
у меня на киткате (SGS3) была такая проблема просто при переключении табов браузера, а на CM11 на этом же аппарате - не было.
Проблема в пересоздании активити. Кажется на андроид это не решить без костылей
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question