Is it possible to change the context of a WebView after it has been instantiated?

后端 未结 2 1289
予麋鹿
予麋鹿 2021-01-04 14:12

I have a WebView I\'m loading in an activity in order to have it preloaded so that it pops up immediately in a different Activity (launched from th

2条回答
  •  时光说笑
    2021-01-04 14:59

    In my App (it's browser) I have the same problem. I don't like to load WebView every time when user back to App. And I've solved this problem partially. I've overridden onBackPressed() on my HomeActivity and use moveTaskToBack(true) instead of super.onBackPressed(). So when user use system back on HomeActivity it does't destroy Activity and all views. It just minimize the App. Visually it's the same behavior but if user try to run App by launch icon, all views already loaded. I know it's temporary solution and all views can be destroyed by system any time but it gives quite good result. And covers a lot of cases for me.

提交回复
热议问题