我的 onSaveInstanceState() 上有一个简单的订单
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Log.d("FUApp", "savingInstanceState");
if (haveLocation) {
outState.putParcelable("theLocation", theLocation);
Log.d("FUApp", "Location stored");
}
else
{
Log.d("FUApp", "Location wasn't stored");
}
}
然后我有这个方法来启动活动
public void setupStartActivityIntent(Context base, Class clss, Bundle mBundle) {
Intent intent = new Intent(base, clss);
if (mBundle != null) {
intent.putExtras(mBundle);
}
if (currentAPIVersion >= 16) {
Bundle translateBundle = ActivityOptions.makeCustomAnimation(
base,
R.anim.slide_in_left,
R.anim.slide_out_left
).toBundle();
startActivity(intent, translateBundle);
} else {
startActivity(intent);
}
onSaveInstanceState 是否应该在新 Activity 开始之前运行?我正在尝试最小化我的应用正在执行的位置请求的数量。