How to download/display a remote image in your Android app without a library? Q-01- Android Interview Question.
Jun 5, 2021
This could be an interview question.
Approach 1.
Create a thread and get the bitmap and then send it back to the main thread.
Approach 2.
Using coroutines.
How to download the image from the URL.
- You can create a separate function and then open an HTTP connection.
- Start the connection and get the input stream.
- Call the function BitmapFactory.decodeStream(inputStream) and pass the input stream as a parameter and this will give the bitmap.
- Return this bitmap to the function call.
- After that set this bitmap to the image view.
You can follow the code from this link.
Hope! This will help.