Kleorence Kleorence - 3 years ago 188
Android Question

Unable to fetch image from Picasso

I am using Picasso to fetch my image into Listview. Then i use getIntent() to get all the particular data to another page. I am able to get all the data but it show error in the image part :

W/System.err: java.io.FileNotFoundException: http://fypestem.com/lecturer/com.squareup.picasso.PicassoDrawable@52a285
W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:238)


Although the error is clear, but I dunno other way to change com.squareup.picasso.PicassoDrawable@52a285 because it should be upload/image.jpg. This is my code:

public class lecturer_details_modify extends AppCompatActivity implements View.OnClickListener{

private static final String TAG_ID="lecID";
private static final String TAG_IMAGE="image";
String lecID,lecName,lecPass,lecEmail,lecImage;
TextView tvLecturer_modify1;
EditText etLecturer_modify1,etLecturer_modify2,etLecturer_modify3;
ImageView ivLecturer_modify1;

private int PICK_IMAGE_REQUEST = 1;

private Bitmap bitmap;

JSONParser jsonParser = new JSONParser();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lecturer_details_modify);
findViewById();
Intent i=getIntent();
lecID=i.getStringExtra(TAG_ID);
lecImage=i.getStringExtra(TAG_IMAGE);

@Override
protected Bitmap doInBackground(String... params) {
String add="http://fypestem.com/lecturer/" +lecImage;
URL url=null;
Bitmap image=null;
try {
url = new URL(add);
image = BitmapFactory.decodeStream(url.openConnection().getInputStream());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
}
GetImage gi=new GetImage();
gi.execute(lecImage);
}

Answer Source
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                // PASS THIS WAY
                String lec_Image="fystem.com/lecturer/"+lecturers.get(position).get‌​Image();
                String lec_ID=((TextView) view.findViewById(R.id.lec_ID)).getText().toString();

                Intent in=new Intent(getApplicationContext(),lecturer_details_modify.class);
                in.putExtra(TAG_IMAGE,lec_Image);
                in.putExtra(TAG_NAME,lec_Name);
                in.putExtra(TAG_ID,lec_ID);
                startActivity(in);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download