我正在尝试将一个序列化的对象数组从一个活动传递到另一个活动。但是,如果我附加额外的意图,我无法在第二个活动中到达OnCreate。谁能看到我做错了什么?
来自第一项活动:
public void onDisplayImages(View view){
Intent intent = new Intent(MainActivity.this, ImagesActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable(IMAGE_LIST,mImagesList);
intent.putExtras(bundle);
MainActivity.this.startActivity(intent);
}
这种方式也不起作用:
public void onDisplayImages(View view){
Intent intent = new Intent(MainActivity.this, ImagesActivity.class);
intent.putExtra(IMAGE_LIST,mImagesList);
MainActivity.this.startActivity(intent);
}
mImageList是ImageData对象的ArrayList,其中ImageData扩展了Serializable。当我不试图附加额外的东西时,我会进行第二次活动。
的ImageData:
public class ImageData implements Serializable {
public Bitmap mImage;
public String mName;
public ImageData(String fileName, Context context){
mName = fileName;
File filePath = context.getFileStreamPath(fileName);
try {
FileInputStream fi = new FileInputStream(filePath);
mImage = BitmapFactory.decodeStream(fi);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
我收到此错误
错误:
05-28 16:50:40.540 2731-2731/[myPackageName]/AndroidRuntime﹕ FATAL EXCEPTION: main Process: [myPackageName], PID: 2731 java.lang.IllegalStateException: Could not execute method of the activity –