無法找出爲什麼onSaveInstanceState和onRestoreInstanceState不會輸出Logcat消息,當我單擊主頁按鈕時以及分別恢復應用程序時。onSaveInstanceState和onRestoreInstanceState
public class MainActivity extends ActionBarActivity {
int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onResume() {
super.onResume();
count++;
}
@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
super.onSaveInstanceState(outState, outPersistentState);
Log.d("TAG", count + " was restored");
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
count = savedInstanceState.getInt("count");
Log.d("TAG", count + " was restored");
}
}