我们接电话然后返回的 Activity将会被毁了重新创建 所以我们需要在摧毁记录一些信息还原Activity

摧毁时:

//在Activi被摧毁的调用此方法
@Override
protected void onSaveInstanceState(Bundle outState) {
Log.e("fmyText", "onSaveInstanceState");
super.onSaveInstanceState(outState);
outState.putInt("i", i);
}

恢复时调用方法1:

protected void onRestoreInstanceState(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onRestoreInstanceState(savedInstanceState);
Log.e("fmyText", "onRestoreInstanceState");
i =savedInstanceState.getInt("i");
}

方法2:

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
intent = new Intent(this,Second.class);
Log.e("fmyText", "onCreate");
i=savedInstanceState.getInt("i");
}

05-02 02:40