Android - WebView dies on resume
-
19-09-2019 - |
Question
- I have Activity with some data displayed in WebView that I load with
WebView#loadDataWithBaseURL
- Then I have/click menu option that fires
android.content.Intent.ACTION_SEND
- Choose email from the chooser
- Google email comes up (as expected)
- Discard email and hit back button
- Action with WebView tries to
resume
- Bang - I get NullPonterException at line 4380 in WebView.java
if (mWebViewCore.getSettings().getNeedInitialFocus())
since mWebViewCore is now null
The only place in code where mWebViewCore is nullified is at WebView#destroy - how do I recover from this? Do I need to recreate the browser and load my data all over again, that seems pretty wasteful? I really appreciate good suggestion at this point
Solution
Well, I can tell you that I just tested using a WebView
with loadDataWithBaseURL()
, where the page I loaded had a link. Clicking on the link brings up the Browser application, as expected. BACK button-ing out of the Browser brings back my app with the WebView
just fine, no exceptions.
So, either ACTION_SEND
/Gmail are somehow special, or there is something more going on with your app.
Can you replicate the problem in a small project that you can post somewhere?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow