0
Я успешно загрузил файл в quickblox и загрузил его успешно, но ответ представляет собой InputStream, The Documentation сказал, что загружает файл с входным потоком. это мой код.Содержимое QuickBlox, как загрузить изображение из inputStream и баса в ImageView
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) {
}
});
}
Запуск приложения я получаю следующую ошибку
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: at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at com.android.okio.Okio$2.read(Okio.java:113)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at com.android.okio.RealBufferedSource.read(RealBufferedSource.java:48)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at com.android.okio.RealBufferedSource$1.read(RealBufferedSource.java:168)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:635)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:611)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:649)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at 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: at 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: at 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: at com.quickblox.core.Query.notifySuccess(Query.java:372)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at com.quickblox.core.Query$VersionEntityCallback.completedWithResponse(Query.java:404)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at com.quickblox.core.Query.completedWithResponse(Query.java:277)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at android.os.Handler.dispatchMessage(Handler.java:102)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at android.os.Looper.loop(Looper.java:135)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5221)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at java.lang.reflect.Method.invoke(Native Method)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal W/System.err: at 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: at 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 an exception
11-10 12:11:36.889 32360-32360/com.shixxels.thankgodrichard.spotpopfinal D/skia: --- SkImageDecoder::Factory returned null
'android.os.NetworkOnMainThreadException'. Google для этого! – greenapps