3

I am trying to download an image from quickblox backend but I don't know ho to transform the recieved inputstream to a bitmap. Here my code:

QBCustomObjectsFiles.downloadFile(co, "fieldName", new QBEntityCallback<InputStream>(){
        @Override
        public void onSuccess(InputStream result, Bundle params) 
        {
            Bitmap bm= BitmapFactory.decodeStream(result);

            if (bm!=null) 
            {
                job.foto = bm;
            }
            else
            {
                App.getInstance().log("ERROR");
            }
        }

The output error is DECORDER-->DECODER ERROR

Divyang Desai
  • 7,483
  • 13
  • 50
  • 76
Isangi
  • 56
  • 7
  • What do you mean with output error? Please tell how your code flows. Is onSuccess() triggered? – greenapps Sep 25 '16 at 20:56
  • Thank you for your comment @greenapps . Yes, the onSuccess() is reached correcctly. What I mean with the output error is that the app crashes whith this los error: – Isangi Sep 27 '16 at 19:56
  • D/skia: ---- read threw an exception D/skia: --- decoder->decode returned false The result.tostream() is: com.quickblox.core.request.ProgressHttpEntityWrapper$ProgressFilterInputStream@c913d95 – Isangi Sep 27 '16 at 20:04
  • Dont decode the stream with bitmap factory but save all bytes to file. After that examine at ease. – greenapps Sep 27 '16 at 20:06
  • What do you mean? How? – Isangi Sep 27 '16 at 21:13
  • I dont understand your error. BitmapFactory.decodeStream() will return a valid bitmap or null. Now what does it return? – greenapps Sep 27 '16 at 21:16
  • `What do you mean? How?` ?? Those are two questions. And they do not match. – greenapps Sep 27 '16 at 21:18

0 Answers0