0

In first activity

intent.putExtra("image",lists.getImageUri());    

in second activity:

imag.setImageResource(getIntent().getIntExtra("image",00));
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
alok verma
  • 97
  • 7
  • 1
    You forgot to ask a question... – eesiraed Apr 07 '18 at 02:51
  • i'm using this to transfer image,but this is not working for me,i'm new in android . – alok verma Apr 07 '18 at 02:52
  • 1
    Put this in the question itself, and be more specific on why it does not work. "It's not working" is not a problem statement. – eesiraed Apr 07 '18 at 02:53
  • sir,,the problem here is that the image is missing in second activity..when i click on any item in first activity.....And i have double checked all the reference still it remains same. – alok verma Apr 07 '18 at 03:05

2 Answers2

1

First Activity

Intent.putExtra("image",lists.getImageUri());

Second Activity

Intent intent= getIntent();
ImageView imageView =(ImageView)
findViewById(R.id.imageView);        strImage=String.valueOf(intent.getStringExtra("Image");    ImageView.setImageResource(strImage);
Rohit Suthar
  • 967
  • 9
  • 22
  • 1
    thanks it works with some changes... Intent intent= getIntent(); String strImage=String.valueOf(intent.getStringExtra("image")); Glide.with(this).load(strImage).into(imag); – alok verma Apr 07 '18 at 03:28
0

You don't need to use putExtra for passing a single image uri to Intent. You can use setData like this:

Intent i = new Intent();
i.setData(lists.getImageUri());

then you can get the uri in the second activity with:

Uri uri = intent.getData();
imag.setImageURI(uri);
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96