我有三项活动:MessagesActivity
,MessagesAttachPhotoActivity
和ImageGalleryActivity
。从MessagesActivity
开始,我按照以下方式启动MessagesAttachPhotoActivity
,
intent = new Intent(this, MessagesAttachPhotoActivity.class);
bundle = new Bundle();
bundle.putInt("Request", MessageThread.MessageType.IMAGE);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivityForResult(intent, MessageThread.MessageType.IMAGE);
然后从MessagesAttachPhotoActivity
开始ImageGalleryActivity
,如下所示;
intent = new Intent(this, MessagesAttachPhotoActivity.class);
bundle = new Bundle();
bundle.putInt("Request", MessageThread.MessageType.IMAGE);
intent.putExtras(bundle);
startActivityForResult(intent, MessageThread.MessageType.IMAGE);
在ImageGalleryActivity
中,我将结果返回MessagesAttachPhotoActivity
Intent photoIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putString("item", imagePath);
photoIntent.putExtras(bundle);
setResult(Activity.RESULT_OK, photoIntent);
finish();
问题是,evrytime我从ImageGalleryActivity
返回,创建了一个新的MessagesAttachPhotoActivity
实例。我怎么能避免这个?我想从ImageGalleryActivity
访问MessagesAttachPhotoActivity
约20次。请有人帮忙。