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.
Asked
Active
Viewed 1,569 times
0
-
you should be adding up a code segment in your question. without that, its difficult to guess what you are trying to achieve – Veer3383 Aug 25 '16 at 06:15
-
here is my adapter code : https://jsfiddle.net/4co6gh7z/ – SUNITHA Aug 25 '16 at 06:32
-
Possible duplicate of [How do I get extra data from intent on Android?](http://stackoverflow.com/questions/4233873/how-do-i-get-extra-data-from-intent-on-android) – Shaishav Jogani Aug 25 '16 at 07:45
-
sry.. Iam not getting.. still it is not working – SUNITHA Aug 25 '16 at 10:00
3 Answers
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
-
Im using holder.ivIcon, where im holding image url.. so how i have to use SecondActivity.KEY_IMAGE_URL, image_url – SUNITHA Aug 25 '16 at 10:03
-