user4051583
user4051583

Reputation:

Pass Image url through intent to a another activity

I'm new to android and I am using Picasso to receive image from my localhost.I want to pass image via intent to another new activity but I'm unable to display the image in my layout.Help me to figure out this problem.

This is my Movie.class

public class Movie {

private String Sno;
private String Name;
private String Director;
private String Image;

public String getSno() {
    return Sno;
}

public void setSno(String sno) {
    Sno = sno;
}

public String getName() {
    return Name;
}

public void setName(String name) {
    Name = name;
}

public String getDirector() {
    return Director;
}

public void setDirector(String director) {
    Director = director;
}

public String getImage() {
    return Image;
}

public void setImage(String image) {
    Image = image;
}

}

MyFragment.class

    public void onClick(View v, int position, boolean isLongClick) {
    String Sno =movieList.get(position).getSno().toString();
    String Name = movieList.get(position).getName().toString();
    String strDirector =         movieList.get(position).getDirector().toString();
    String strImage = movieList.get(position).getImage().toString();

    Intent intent = new Intent(getActivity(),Movie_detail.class);
    intent.putExtra("Sno",Sno);
    intent.putExtra("Director",strDirector);
    intent.putExtra("Name",Name);
    intent.putExtra("Image",strImage);

    startActivity(intent);
    }

Movie_detail.class

    Intent intent= getIntent();
    ImageView imageView = (ImageView) findViewById(R.id.imageView);
    strImage= String.valueOf(intent.getStringExtra("strImage"));

    Picasso.with(this)
            .load(strImage)
            .into(imageView);

Upvotes: 1

Views: 2954

Answers (2)

vikram singh chandel
vikram singh chandel

Reputation: 11

Intent intent= getIntent();

    ImageView imageView = (ImageView) findViewById(R.id.imageView);

    strImage= String.valueOf(intent.getStringExtra("Image"));

    Log.d("LOG_TAG" strImage);
    Picasso.with(this)
            .load(strImage)
            .into(imageView);

try to focus on elements which is inside double quotes.

Upvotes: 0

Sergey Zabelnikov
Sergey Zabelnikov

Reputation: 1955

Try to use this code and see what do you have in strImage and paste here in comment

Updated:

 Intent intent= getIntent();
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        strImage= String.valueOf(intent.getStringExtra("Image"));
        Log.d("LOG_TAG" strImage);
        Picasso.with(this)
                .load(strImage)
                .into(imageView);

Upvotes: 0

Related Questions