i want to select image in one fragment and display it in another fragment.
how can i do this.
my code is this but not working
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent gallery = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivityForResult(gallery, 100);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
Uri imageUri;
if (resultCode == RESULT_OK && requestCode == 100){
imageUri = data.getData();
file1path = imageUri.getPath();
TVfrontimg.setText(file1path);
}
}
and i send this using bundle
Bundle bundle = new Bundle();
bundle.putString("image1", file1path);
registerPartThreeFragment.setArguments(bundle);
transaction.replace(R.id.FLcontainer, registerPartThreeFragment);
transaction.addToBackStack(null);
transaction.commit();
in another fragment
String imgPath = getArguments().getString("image1");
Bitmap bitmap = BitmapFactory.decodeFile(String.valueOf(new File(imgPath)));
imageview.setImageBitmap(bitmap);
but its not working.please help.
its giving me this error
2020-05-30 00:16:20.808 8995-8995/com.example.deliveryapp E/BitmapFactory: Unable to decode stream: java.io.FileNotFoundException: /raw/storage/emulated/0/DCIM/Camera/IMG_20200319_173033.jpg (No such file or directory)