하나의 CheckBox로 매우 간단한 애플리케이션을 가지고 있습니다. 나는 안드로이드가 내 활동을 망칠 때이 체크 박스의 상태가 목록이 될 것이라고 생각했다. 실제로는 체크 박스가 계속 선택됩니다.안드로이드 CheckBox는 파손 된 후에도 상태가 유지됩니다.
onDestroy()는 실제로 호출됩니다 (순환시 또는 다른 응용 프로그램으로 전환 할 때 -> 내 에뮬레이터에이 dev 구성이 있음).
그럼 왜이 기능은 onRestoreInstanceState() 및 onSaveInstanceState()를 사용하지 않고도 작동합니까?
Android 타겟은 4.2 Jelly Bean입니다. 여기
내 활동 :
여기public class CoffeeMixerActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coffee_mixer);
}
protected void onDestroy() {
super.onDestroy();
Log.d("MyMessage", "Destroy my app");
}
}
내 레이아웃 파일 :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".CoffeeMixerActivity" >
<CheckBox
android:id="@+id/checkBoxSprinkles"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Sprinkles" />
</RelativeLayout>