Android - WebView 在恢复时死亡
- 我的 Activity 中显示了一些在 WebView 中显示的数据,我使用
WebView#loadDataWithBaseURL
加载 - 然后我有/单击菜单选项来触发
android.content.Intent.ACTION_SEND
- 从选择器
- Google 电子邮件出现(如预期)
- 丢弃电子邮件并点击后退按钮
- WebView 的操作尝试
恢复
- Bang - 我在 WebView.java
if (mWebViewCore.getSettings() 中的第 4380 行得到 NullPonterException .getNeedInitialFocus())
因为 mWebViewCore 现在为 null
代码中 mWebViewCore 无效的唯一位置是 WebView#destroy - 我该如何恢复?我是否需要重新创建浏览器并重新加载我的数据,这看起来很浪费?我真的很感激此时的好建议
- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我可以告诉你,我刚刚使用
WebView
和loadDataWithBaseURL()
进行了测试,我加载的页面有一个链接。单击该链接将按预期打开浏览器应用程序。从浏览器中按“后退”按钮可以正常返回我的带有WebView
的应用程序,没有例外。因此,要么
ACTION_SEND
/Gmail 有点特殊,要么您的应用程序发生了其他情况。您能否在一个小项目中复制该问题并发布到某个地方?
Well, I can tell you that I just tested using a
WebView
withloadDataWithBaseURL()
, 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 theWebView
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?