web-dev-qa-db-ja.com

java.lang.RuntimeException:Parcelableでシリアル化可能なオブジェクトの書き込み中にIOExceptionが発生しましたAndroid ArrayListオブジェクトを渡しています

Serializableを実装するDataWrapperを使用して、ArrayListオブジェクトを別のアクティビティに渡します。
私はここで提供される答えに従いました: ユーザー定義オブジェクトのarraylistをIntent Androidに渡す
MPAndroidChartライブラリPieChartOnChartGestureListener()から別のアクティビティを開始しています。これは、ArrayListオブジェクトthreadListを渡す方法です。

mChart.setOnChartGestureListener(new OnChartGestureListener() {
@Override
public void onChartSingleTapped(MotionEvent me) {
    Intent intent = new Intent(MainActivity.this, TextersSmsActivity.class);
    intent.putExtra("threadList", new DataWrapper(threadList));
    MainActivity.this.startActivity(intent);
}
//.....
}

私は次のようにDataWrapperクラスを実装しました:

public class DataWrapper implements Serializable {
private static final long serialVersionUID = 100L;
private ArrayList<OneThread> threadList;

   public DataWrapper(ArrayList<OneThread> threadList) {
      this.threadList = threadList;
   }

   public ArrayList<OneThread> getThreadList() {
      return threadList;
   }
}

そしてParcelable encountered IOException writing serializable objectエラー。ここに私のLogcatがあります:

11-29 21:12:09.919: E/MessageQueue-JNI(21550): Java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.myproj.DataWrapper)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.os.Parcel.writeSerializable(Parcel.Java:1316)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.os.Parcel.writeValue(Parcel.Java:1264)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.os.Parcel.writeArrayMapInternal(Parcel.Java:618)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.os.Bundle.writeToParcel(Bundle.Java:1692)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.os.Parcel.writeBundle(Parcel.Java:636)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.content.Intent.writeToParcel(Intent.Java:7013)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.Java:2076)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Instrumentation.execStartActivity(Instrumentation.Java:1419)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Activity.startActivityForResult(Activity.Java:3424)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Activity.startActivityForResult(Activity.Java:3385)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.Java:817)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Activity.startActivity(Activity.Java:3627)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Activity.startActivity(Activity.Java:3595)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.myproj.MainActivity$11.onChartSingleTapped(MainActivity.Java:967)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.github.mikephil.charting.listener.PieRadarChartTouchListener.onSingleTapUp(PieRadarChartTouchListener.Java:89)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.GestureDetector.onTouchEvent(GestureDetector.Java:595)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.github.mikephil.charting.listener.PieRadarChartTouchListener.onTouch(PieRadarChartTouchListener.Java:40)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.github.mikephil.charting.charts.PieRadarChartBase.onTouchEvent(PieRadarChartBase.Java:56)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.View.dispatchTouchEvent(View.Java:7706)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.Java:2216)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewGroup.dispatchTouchEvent(ViewGroup.Java:1959)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.Android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.Java:2068)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.Android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.Java:1515)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.app.Activity.dispatchTouchEvent(Activity.Java:2458)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.support.v7.app.ActionBarActivityDelegateICS$WindowCallbackWrapper.dispatchTouchEvent(ActionBarActivityDelegateICS.Java:268)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at com.Android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.Java:2016)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.View.dispatchPointerEvent(View.Java:7886)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.Java:3947)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.Java:3826)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.Java:3392)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.Java:3442)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.Java:3411)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.Java:3518)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.Java:3419)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.Java:3575)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.Java:3392)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.Java:3442)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.Java:3411)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.Java:3419)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.Java:3392)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.Java:5532)
11-29 21:12:09.919: E/MessageQueue-JNI(21550):  at Android.view.ViewRootImpl.doP

上記のリンクで(配列リストオブジェクトを渡すために)回答をたどりましたが、エラーが発生しました。エラーの原因と削除方法は?

11
Mohammed Ali

OneThreadクラスもSerializableを実装する必要があります。すべてのサブクラスと内部サブクラスはSerializableを実装する必要があります。

42
MathanG