【发布时间】:2015-09-09 11:53:35
【问题描述】:
是否有代码可以用来测试 onCreate() 是否第一次被调用?
例如
if (condition) {
code that runs if the app runs for the first time
}else{
code that runs if activity is started because of configuration changes, orientation changes...
}
【问题讨论】:
-
在顶部声明一个变量 i。然后为每个 oncreate 方法调用递增 i 。如果 1 == 1,那么......。