[英]OnCreate method keeps calling OnResume method
So i have this app and everytime i start the main activity the OnResume
method gets called.i have put a Toast
message in both the OnCreate
and OnResume
methods and everytime i start the Activity
both Toasts
show. 所以我有这个程序,并每次我启动主活动
OnResume
方法获取called.i已经把Toast
两个消息OnCreate
和OnResume
方法,每次我开始的Activity
都Toasts
演出。 Is there something i am missing here? 我在这里缺少什么吗? I have looked at the code line by line but found nothing that might be causing this.
我逐行查看了代码,但没有发现任何可能导致此问题的原因。
You need to create some condition and call recreate only if that condition is satisfied. 您需要创建一些条件,仅在满足该条件时才调用recreate。 assign a boolean variable if your condition is satisfied and call recreate if this boolean is true or false as per your condition, Otherwise your loop will never stop.
如果您的条件满足,则分配一个布尔变量,如果根据条件该布尔值为true或false,则调用recreate,否则循环将永远不会停止。
private boolean isCheck = false;
onCreate() {
if(somecondition == true) {
isCheck = true;
}
}
onResume() {
if(!isCheck){
recreate();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.