Android - WebView 在恢复时死亡

发布于 2024-08-11 00:07:13 字数 538 浏览 2 评论 0原文

  1. 我的 Activity 中显示了一些在 WebView 中显示的数据,我使用 WebView#loadDataWithBaseURL 加载
  2. 然后我有/单击菜单选项来触发 android.content.Intent.ACTION_SEND
  3. 从选择器
  4. Google 电子邮件出现(如预期)
  5. 丢弃电子邮件并点击后退按钮
  6. WebView 的操作尝试恢复
  7. Bang - 我在 WebView.java if (mWebViewCore.getSettings() 中的第 4380 行得到 NullPonterException .getNeedInitialFocus()) 因为 mWebViewCore 现在为 null

代码中 mWebViewCore 无效的唯一位置是 WebView#destroy - 我该如何恢复?我是否需要重新创建浏览器并重新加载我的数据,这看起来很浪费?我真的很感激此时的好建议

  1. I have Activity with some data displayed in WebView that I load with WebView#loadDataWithBaseURL
  2. Then I have/click menu option that fires android.content.Intent.ACTION_SEND
  3. Choose email from the chooser
  4. Google email comes up (as expected)
  5. Discard email and hit back button
  6. Action with WebView tries to resume
  7. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赏烟花じ飞满天 2024-08-18 00:07:13

好吧,我可以告诉你,我刚刚使用 WebViewloadDataWithBaseURL() 进行了测试,我加载的页面有一个链接。单击该链接将按预期打开浏览器应用程序。从浏览器中按“后退”按钮可以正常返回我的带有 WebView 的应用程序,没有例外。

因此,要么 ACTION_SEND/Gmail 有点特殊,要么您的应用程序发生了其他情况。

您能否在一个小项目中复制该问题并发布到某个地方?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文