I have 2 activities and both have an Imageview, I want to pass Image taken from camera/gallery on activty one to activity 2. I don't want to pass Image itself I want to pass URI(and than set the uri to bitmap of activity 2 and Imageview) of the Image so it would consume less memory but I don't know the Way. Please Help Me. PS: If image is not taken/not selected from Gallery the ImageView of Activity 2 should show "Nothing Selected"
Asked
Active
Viewed 2,528 times
1 Answers
3
Simply pass your image path as String in intent :
intent.putExtra("imagePath", imageFilePath);
Get image path from intent and load using BitmapFactory :
String imagePath = getIntent().getStringExtra("imagePath");
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);
imageView.setImageDrawable(bitmap);

Haresh Chhelana
- 24,720
- 5
- 57
- 67
-
The "imageFilePath" is String Right? That is Converted from URI? – Siddharth Nov 29 '14 at 12:42
-
Yes is String and no need to convert URI. – Haresh Chhelana Nov 29 '14 at 12:43
-
1change your last line of code to : `imageView.setImageBitmap(bitmap);` for it to work – Nike15 Jun 09 '16 at 13:00