我想将 OAScene 场景对象发送到下一个 Activity 类,但我不能。它立即停止应用程序..如果我打开其他活动类而不使用 putExtra 方法它可以工作......但在我的情况下我需要发送对象......
这是代码
public void setScene(OAScene scene) {
final OAScene _scene = scene;
this.currentScene = scene;
setColor(color_black);
double dis;
dis = CalculationByDistance(latitudeOri, latitudeOri, scene.getLatitude(), scene.getLongitude());
// Set the text fields of the notification bubble to match the data of
// the selected scene.
popup_name.setText("Name: " + scene.getName());
popup_text.setText("Distance: " + dis + "m");
more_info.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
OAScene scene=_scene;
Intent FacilityIntent;
FacilityIntent = new Intent(getContext(), MapViewActivity.class);
FacilityIntent.putExtra("scene", _scene);
getContext().startActivity(FacilityIntent);
}
});
}
日志..
01-20 15:50:31.196: E/AndroidRuntime(21403): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.hitlabnz.outdoorar.api.OAScene)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Parcel.writeSerializable(Parcel.java:1181)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Parcel.writeValue(Parcel.java:1135)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Parcel.writeMapInternal(Parcel.java:493)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Bundle.writeToParcel(Bundle.java:1612)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Parcel.writeBundle(Parcel.java:507)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.content.Intent.writeToParcel(Intent.java:6190)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1696)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1382)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.app.Activity.startActivityForResult(Activity.java:3190)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.app.Activity.startActivity(Activity.java:3297)
01-20 15:50:31.196: E/AndroidRuntime(21403): at com.hitlabnz.tutorialbasic.TutorialSceneNotificationBubble$2.onClick(TutorialSceneNotificationBubble.java:141)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.view.View.performClick(View.java:3620)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.view.View$PerformClick.run(View.java:14292)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Handler.handleCallback(Handler.java:605)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Handler.dispatchMessage(Handler.java:92)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.os.Looper.loop(Looper.java:137)
01-20 15:50:31.196: E/AndroidRuntime(21403): at android.app.ActivityThread.main(ActivityThread.java:4512)
01-20 15:50:31.196: E/AndroidRuntime(21403): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 15:50:31.196: E/AndroidRuntime(21403): at java.lang.reflect.Method.invoke(Method.java:511)
代码接收意图:
Intent i = getIntent();
OAScene scene = (OAScene)i.getSerializableExtra("scene");