我有 fragment A,它会通过点击按钮调用 fragment B。
Fragment a = FragmentA
.getInstance();
// Supply index input as an argument.
Bundle args = new Bundle();
args.putBoolean(GlobalConstants.WANT_START_GAME, false);
pokerOnlineProject.setArguments(args);
FragmentTransaction transaction = getFragmentManager()
.beginTransaction();
transaction.replace(R.id.poker_online_container, A,
"A");
transaction.addToBackStack(null);
transaction.commit();
在这个 fragment B 中,我使用以下代码在 android 操作系统中调用相机应用程序:
Intent i = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);
之后,我单击后退按钮,我的应用程序将返回 fragment A 而不是 fragment B,当我尝试触摸 fragment A 上的按钮时出现异常“fragment 已激活”。
最佳答案
您的照片保存在PATH_TO_SAVE 位置。
你应该在 onActivityResult 中做这样的事情:
File file = new File(PATH_TO_SAVE);
Bitmap bmp = BitmapFactory.decodeFile(file.getPath());
关于android - 从拾取相机 Intent 回来后 fragment 已经激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18586623/