android - QuickBlox Content, How to download the image from inputStream and bass to ImageView -


i uploaded file quickblox , download successfully, response inputstream, documentation said download file input stream. code.

public void downloadprofilepic(int id, final imageview v, final context c){     qbusers.getuser(id, new qbentitycallback<qbuser>() {         @override         public void onsuccess(qbuser user, bundle args) {             log.i("propix", string.valueof(user.getfileid()));             qbcontent.downloadfilebyid(user.getfileid(), new qbentitycallback<inputstream>(){                 @override                 public void onsuccess(inputstream inputstream, bundle params) {                     bitmap bmp = bitmapfactory.decodestream(inputstream);                     v.setimagebitmap(bmp);                 }                  @override                 public void onerror(qbresponseexception errors) {                     log.i("propic",errors.getmessage());                     v.setimageresource(r.mipmap.profile_img);                 }             }, new qbprogresscallback() {                 @override                 public void onprogressupdate(int progress) {                  }             });           }          @override         public void onerror(qbresponseexception errors) {          }     });  } 

running app following error

11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err: android.os.networkonmainthreadexception 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.os.strictmode$androidblockguardpolicy.onnetwork(strictmode.java:1147) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.org.conscrypt.opensslsocketimpl$sslinputstream.read(opensslsocketimpl.java:657) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.okio.okio$2.read(okio.java:113) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.okio.realbufferedsource.read(realbufferedsource.java:48) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.okhttp.internal.http.httpconnection$fixedlengthsource.read(httpconnection.java:442) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.okio.realbufferedsource$1.read(realbufferedsource.java:168) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.quickblox.core.request.progresshttpentitywrapper$progressfilterinputstream.read(progresshttpentitywrapper.java:96) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.graphics.bitmapfactory.nativedecodestream(native method) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.graphics.bitmapfactory.decodestreaminternal(bitmapfactory.java:635) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:611) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:649) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.shixxels.thankgodrichard.spotpopfinal.helpers$27$1$override.onsuccess(helpers.java:849) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.shixxels.thankgodrichard.spotpopfinal.helpers$27$1$override.access$dispatch(helpers.java) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.shixxels.thankgodrichard.spotpopfinal.helpers$27$1.onsuccess(helpers.java:0) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.shixxels.thankgodrichard.spotpopfinal.helpers$27$1.onsuccess(helpers.java:845) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.quickblox.core.query.notifysuccess(query.java:372) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.quickblox.core.query$versionentitycallback.completedwithresponse(query.java:404) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.quickblox.core.query.completedwithresponse(query.java:277) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.quickblox.core.server.httprequestrunnable$1.handlemessage(httprequestrunnable.java:42) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.os.handler.dispatchmessage(handler.java:102) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.os.looper.loop(looper.java:135) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ android.app.activitythread.main(activitythread.java:5221) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ java.lang.reflect.method.invoke(native method) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ java.lang.reflect.method.invoke(method.java:372) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:899) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal w/system.err:     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:694) 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal d/skia: ---- read threw exception 11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal d/skia: --- skimagedecoder::factory returned null 

i found out error because trying download picture main thread. code works.

public void downloadprofilepic(int id, final imageview v, final context c, final activity ac){     qbusers.getuser(id, new qbentitycallback<qbuser>() {         @override         public void onsuccess(qbuser user, bundle args) {             log.i("propix", string.valueof(user.getfileid()));             qbcontent.downloadfilebyid(user.getfileid(), new qbentitycallback<inputstream>(){                  @override                 public void onsuccess(final inputstream inputstream, bundle params) {                     new thread(new runnable() {                         @override                         public void run() {                             final bitmap bmp = bitmapfactory.decodestream(inputstream);                             ac.runonuithread(new runnable() {                                 @override                                 public void run() {                                     v.setimagebitmap(bmp);                                 }                             });                         }                     }).start();                    }                  @override                 public void onerror(qbresponseexception errors) {                     log.i("propic",errors.getmessage());                     v.setimageresource(r.mipmap.profile_img);                 }             }, new qbprogresscallback() {                 @override                 public void onprogressupdate(int progress) {                  }             });           }          @override         public void onerror(qbresponseexception errors) {          }     });  } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -