I want to send the ImageView form one activity to another activity. When i am trying to pass the image view from Class A to Class B using bundle concept then in class B it\'
You shouldn't be passing views between activities. You should use extras to pass the location of the image in the intent and load it again in your new activity.
Ex:
Intent intent = new Intent(context, MyActivity.class);
intent.putExtra("imagePath", pathToImage);
startActivity(intent);
And in you receiving activity:
String path = getIntent().getStringExtra("imagePath");
Drawable image = Drawable.createFromPath(path);
myImageView.setImageDrawable(image);
You absolutely do not want to pass an image view from one activity to another. Views
keep a reference to their ViewContainer
and parent Activity
. This prevents the Garbage Collector from clearing up memory when the Activity
that owns the View
gets hidden or closes. Instead you should pass the information required to replicate the ImageView
from activity to another using Intents
.