0

I am new to Android apps. I'm doing JSON parsing for my listview. When I click on my list Image I need to pass that Image to second activity. I'm trying to pass it using intent and bundles. But I have image URL so I don't know how to pass it. I searched everywhere others are passing bitmaps or id.

halfer
  • 19,824
  • 17
  • 99
  • 186
SUNITHA
  • 23
  • 8

3 Answers3

0

your first activity

Intent intent = new Intent(MainActivity.this,AnotherActivity.class);
intent.putExtras("IMAGE_URL",your_image_url);
startActivity(intent);

in Second activity where you want data

Bundle bundle = getIntent().getExtras();
String image_url =bundle.getString("IMAGE_URL");

pass image_url from one activity to another activity, and then use picasso lib to show image.

Nikhil Borad
  • 2,065
  • 16
  • 20
  • no actually i stored my image url in a view holder.. from there i have to pass.. here is my custom adapter code: https://jsfiddle.net/4co6gh7z/ – SUNITHA Aug 25 '16 at 06:33
0

Class- FirstActivity

Bundle bundle= new Bundle();
bundle.putString("imageUrl",<url for image>);
Intent i= new Intent(FirstActivity.this,SecondActivity.this);
i.putExtras(bundle);
statrActivity(i)

Class- SecondActivity

Bundle bundle = getIntent().getExtras();
String image_url =bundle.getString("imageUrl");
Amit Bhati
  • 1,405
  • 12
  • 20
0

In FirstActivity, in the onClickListener, add this

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);

intent.putExtras(SecondActivity.KEY_IMAGE_URL, image_url);
startActivity(intent);

And in SecondActivity

public static final String KEY_IMAGE_URL = "image_url";

@Override
protected void onCreate(Bundle savedInstanceState) {
    ...

    if (getIntent().hasExtra(KEY_IMAGE_URL)) {
        String imageUrl = getIntent().getStringExtra(KEY_IMAGE_URL);
    }
}
Ruben Renzema
  • 219
  • 1
  • 2
  • 13