• Register
0 votes

Problem :

I am beginner to Android. I want to transfer a image from one activity to another using Intent. In the first activity a user must select the image from many images from a scroll view and after that a image must be displayed in a imageview of very next activity. How can I achieve this with the help of Intent ?

8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have understood your problem. Please go through below solution on it.

The easiest way to achieve this is with the use of intent.

First you must create the static variable in one of the class as below :

public class MyClass{

public static Bitmap MYPHOTO = null;


After that you should get the bitmap from a gallery just to save that bitmap in your MYPHOTO variable.

If you are willing to get the photo from your camera then code is as below.

Intent myintent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(myintent, CAMERA_PIC_REQUEST);

After this you should write below code:

    public void onActivityResult(int myrequestCode,  int myresultCode, Intent mydata) {
        if (myresultCode == Activity.RESULT_OK) {

            switch (myrequestCode) {
                case CAMERA_PIC_REQUEST:
                    Bitmap myb = (Bitmap) mydata.getExtras().get("mydata");
                    if (myb != null) {
                        MyClass.MYPHOTO = myb;

Now you can use your MYPHOTO variable in any other Activity.

You can use the same way if you want to pick photo from the gallery.

5 2 1
4,980 points

Related questions

1 vote
1 answer 16 views
Problem: I want to know : How to pass data from one activity to another in android example . I have basic knowledge in android programming. I have one scenario where just after logging in through my login page then there will be the sign-out button on each of the ... my signed in user to the sign-out. Can someone guide me on how can I keep my session id available to all of the activities?
asked Jul 1, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 10 views
0 votes
1 answer 13 views
0 votes
1 answer 9 views
0 votes
1 answer 17 views
0 votes
1 answer 26 views
0 votes
1 answer 8 views
I need to move the map by keeping the marker in certer android programmically.
asked Oct 4, 2020 Daniel Anderson 4k points