onRestoreInstanceStateは、画面の向きを変更し、エミュレーター設定devtools / Development Settings / maxappprocessを変更することでテストできます。maxは1に設定されています。onRestoreInstanceStateは画面の向きで機能しますが、最大アプリプロセスを1に設定してアプリを再起動するとクラッシュします。Debug.waitForDebugger();を使用しました。1に設定された最大アプリプロセスのデバッガーを接続します。
ビューでは、解析可能ファイルが保存され、再帰的に復元されます。
復元:
MyClass(Parcel in) {
boolean boolValues[] = new boolean[2];
in.readBooleanArray(boolValues);
if (boolValues[1])
{
next = in.readParcelable(MyClass.class.getClassLoader());
}
//
//recurse here
}
保存:
public void writeToParcel(Parcel out, int flags) {
// TODO Auto-generated method stub
boolean boolValues[] = new boolean[2];
boolValues[0] = aValue;
boolValues[1] = next != null;
out.writeBooleanArray(boolValues);
if (boolValues[1])
{
out.writeParcelable(next,flags);
}
}