Android WebView 在应用程序加载时重新加载

发布于 2024-09-14 19:25:54 字数 243 浏览 3 评论 0原文

我正在编写一个带有 webview 的 Android 应用程序。第一次加载时它工作正常,我可以浏览并深入到页面。我的预期行为是,如果我离开应用程序并返回,它应该重定向到我设置为在 webView.loadUrl("[page i set here]") 中调用的页面,但它似乎加载了该页面我上次使用它时是最后一次。

如何在 onStop() 方法中终止应用程序?或者,我是否应该做其他事情,以便它在每次加载时重新启动应用程序。

提前致谢!

I am writing an android application that has a webview. On the first load it works fine, I am able to browse and drill down to pages. My expected behavior is that if I leave the application and come back, it should redirect to the page that I have it set to call in the webView.loadUrl("[page i set here]") but it seems to load the page that I was last on when I last used it.

How can I kill the app in the onStop() method? Or, am I supposed to do something else in order for it to restart the application on every load.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

小清晰的声音 2024-09-21 19:25:54

您将确保您的应用程序结束,

public void finish() {
        super.finish();
}

以便下次您的网络视图将再次加载代码中的指定页面

you will ensure the end of your app with

public void finish() {
        super.finish();
}

so the next time your webview will load the specified page in your code again

陌生 2024-09-21 19:25:54

我同意 Mayra 的观点,但如果您确实需要这个,请尝试将逻辑放入 onResume 方法中。

I'm agree with Mayra, but if you really need this, try to put the logic to the onResume method.

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