如何重新启动onCreate函数
我有一个应用程序,并且在某些条件下我希望重新创建我的 Activity 或需要调用 onCreate
函数以便可以再次执行不同的函数。就像当设备的方向发生变化并调用 oncreate 函数或重新创建 Activity 时一样,我希望重新启动我的应用程序。目前我正在使用 this.onCreate(null)
但我认为这不是最好的方法..
请给一些建议。
多谢
I have an application and there are certain conditions when I want my activity to be recreated or the onCreate
function is needed to be called so that different functions can be performed again. Just like when the orientation of the device changes and the oncreate function is recalled or the activity is recreated, in the same way, I want my application to be restarted. Currently I am using this.onCreate(null)
but I think this is not the best way..
Please give some suggestions.
Thanks alot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如何在 onCreate() 之外创建一个方法来完成所有活动的工作,并在 onCreate 方法中调用该方法来加载活动。如果您需要刷新 Activity,只需调用该新方法即可。例如:
How about creating a method outside of your onCreate() that does all of the Activities work, and in your onCreate method, it calls that to load the Activity. If you need to refresh your Activity, just call that new method. For example: