Android WebView 在应用程序加载时重新加载
我正在编写一个带有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您将确保您的应用程序结束,
以便下次您的网络视图将再次加载代码中的指定页面
you will ensure the end of your app with
so the next time your webview will load the specified page in your code again
我同意 Mayra 的观点,但如果您确实需要这个,请尝试将逻辑放入 onResume 方法中。
I'm agree with Mayra, but if you really need this, try to put the logic to the onResume method.
你们俩都是对的,但为了更好地理解,我建议changus理解这个图:
http://www.androidside.com/data/geditor/0812/1062731775_4e7c4d93_android+activity+life+cycle.jpg
以及此页面:
http://developer.android.com/guide/topics/fundamentals.html#lcycles
Both of you are right, but for better understanding, I suggest changus to understand this diagram:
http://www.androidside.com/data/geditor/0812/1062731775_4e7c4d93_android+activity+life+cycle.jpg
as well as this page:
http://developer.android.com/guide/topics/fundamentals.html#lcycles