I have developed one Android application.
The app is performing displayed list view using xml parsing.
I have used below code. The text data is pass from one activity to next activity successfully but the image doesn't pass from one activity to another activity.
How can I pass image from one activity to the next activity in Android application?
This is first activity:
String title = ((TextView) view.findViewById(R.id.title)).getText().toString();
String duration = ((TextView) view.findViewById(R.id.duration)).getText().toString();
String artist = ((TextView) view.findViewById(R.id.artist)).getText().toString();
String image = ((ImageView) view.findViewById(R.id.list_image)).getImageMatrix().toString();
// Starting new intent
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_TITLE, title);
in.putExtra(KEY_DURATION, duration);
in.putExtra(KEY_ARTIST, artist);
in.putExtra(KEY_THUMB_URL, image);
startActivity(in);
This is next activity:
Intent in = getIntent();
// Get XML values from previous intent
String title = in.getStringExtra(KEY_TITLE);
String duration = in.getStringExtra(KEY_DURATION);
String artist = in.getStringExtra(KEY_ARTIST);
Bitmap bitmap =(Bitmap) in.getParcelableExtra(KEY_THUMB_URL);
// Displaying all values on the screen
TextView lblName = (TextView) findViewById(R.id.name_label);
TextView lblCost = (TextView) findViewById(R.id.cost_label);
TextView lblDesc = (TextView) findViewById(R.id.description_label);
ImageView image = (ImageView)findViewById(R.id.image_label);
image.setImageBitmap(bitmap);
lblName.setText(title);
lblCost.setText(duration);
lblDesc.setText(artist);
EDIT:
I have changed the first activity like below code:
String image = ((ImageView) view.findViewById(R.id.list_image)).getImageMatrix().toString();
Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
in.putExtra(KEY_THUMB_URL, image);
I have changed the second activity like below:
static final String KEY_THUMB_URL = "Image";
String Image = in.getStringExtra(KEY_THUMB_URL);
ImageLoader imageLoader = new ImageLoader(getApplicationContext());
ImageView thumb = (ImageView) findViewById(R.id.image_label);
imageLoader.DisplayImage(Image, thumb);
After I have to run the app means I am getting empty image only.