• 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

0 votes
1 answer 10 views
Problem: any Idea that can help me with this: how to pass image from one activity to another in android using intent example
asked Mar 17 Wafa Abu Yousef 6.1k points
0 votes
1 answer 9 views
Problem: Can any one help me out? I am new in python(tag name). Its show this : the activity must be exported or contain an intent-filter.
asked Mar 31 nabin shrestha 4.3k points
1 vote
1 answer 21 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
1 vote
1 answer 4 views
Problem : Please give me any advise > How do I pass the string from an edit text in one activity to another activity on android?
asked 3 days ago Abik Dey 4k points
0 votes
0 answers 4 views
Problem: In my Android application, I have two kinds of activity. I have a button in the first one and I want to show the second one when it is clicked, but it gives me an error. Here are the classes: Java">public class FirstActivity extends Activity { @Override public ... @Override public void onClick(View view) { finish(); } }); } } How can I create a button that will show the second activity?
asked Apr 5 sasha 16.2k points
0 votes
1 answer 15 views
0 votes
1 answer 80 views
Problem: Why I got the error : the activity must be exported or contain an intent-filter. Can some one please help fix this, Help I am new in this language. Any Ideas on what I need to fix this? Thanks in advance.
asked Feb 28 James Smith 8.9k points
1 vote
1 answer 29 views
Problem: the activity must be exported or contain an intent-filter.
asked Feb 23 Ethan ross 2.7k points
0 votes
1 answer 13 views