Reputation: 3
I am making a memegenerator. I have a function that opens the gallery and the user can choose an image.This image is then set to the ImageView. I want to send this image to another activity wherein I can edit the image. How can I do this?
A sincere request to anyone who is answering this question-I am a beginner and i would like detailed answers or explanations.Thank you!
Upvotes: 0
Views: 965
Reputation: 405
Do Following Steps to get Image in the Next Activity:
1. Set ImageView Property Like this:
imageView.setDrawingCasheEnabled(true);
Bitmap b=imageView.getDrawingCashe();
2. Start a new Activity via Intent like this:
Intent i=new Intent(MainActivity.this,NextActivity.class);
i.putExtra("Bitmap",b);
startActivity(i);
3. In the Next Activity Write this:
Intent i=getIntent();
Bitmap b=i.getParcelableExtra("Bitmap");
imageView.setImageBitmap(b);
Upvotes: 0
Reputation: 814
You could save the image locally and add the path as an Intentextra when starting the other activity, like this:
String pathToImage = xxx;
Intent i = new Intent(Photoactivity.this, OtherActivity.class);
i.putExtra("imagePath", pathToImage);
And in the destination Activity:
String imagePath = i.getStringExtra("imagePath");
//After this load the image from disk
Upvotes: 0
Reputation: 1095
Please pass your image uri to your next activity instead of passing the whole bitmap. Passing bitmap is not recommended.
Upvotes: 2