A
A
Alexzatey2020-08-28 17:15:06
Android
Alexzatey, 2020-08-28 17:15:06

Using Retrofit2, I'm trying to get and display png. But it stubbornly throws NullPointerExeption?

What am I doing wrong, every time I try to display an image on the UI, I get NULLPOINTEREXCEPTION ?
Code in response

InputStream inputStream = response.body().byteStream();
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
imageView.setImageBitmap(bitmap);

-----QUERY---
code lang="java">

@GET("img/wn/{image}@2x.png")

Call updateImage(@Path("image") String image);

Retrofit request2 = new Retrofit.Builder()
.baseUrl(base_url)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build();


Server: openresty/1.9.7.1
    Date: Fri, 28 Aug 2020 14:03:29 GMT
    Content-Type: image/png
    Content-Length: 1869
    Last-Modified: Mon, 24 Jun 2019 13:32:32 GMT
    Connection: keep-alive
    ETag: "5d10d0f0-74d"
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Methods: GET
    Access-Control-Allow-Headers: origin, content-type, accept
    Expires: Fri, 04 Sep 2020 14:03:29 GMT
    Cache-Control: max-age=604800
    Accept-Ranges: bytes
D/OkHttp: <-- END HTTP (binary 1869-byte body omitted)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacen11, 2020-08-28
@Jacen11

I really don't understand what the hell are you doing here. Glide or picaso use to upload the picture.
Where does npe take off? what classes are used? where are the normal logs? why should a stream of bytes suddenly decad into a png bitmap? What is going on?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question