I am using an API to make custom QR codes in my android app. I have used this api. Now, to get the QR code, I used this code:
val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{ " +
"\"data\": \"https://google.com\", " +
"\"config\": {" +
"\"body\": \"circular\"," +
"\"eyeBall\": \"ball15\"," +
"\"logo\": \"https://storage.googleapis.com/support-kms-prod/ZAl1gIwyUsvfwxoW9ns47iJFioHXODBbIkrK\" " +
"}," +
"\"size\": 500," +
"\"download\": false," +
"\"file\": \"png\" " +
"}")
val request = Request.Builder()
.url("https://qrcode-monkey.p.rapidapi.com/qr/custom")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("X-RapidAPI-Host", "qrcode-monkey.p.rapidapi.com")
.addHeader("X-RapidAPI-Key", "API_KEY")
.build()
val response = client.newCall(request).execute()
Now, from here, I dont know how to get that image and load it in an image view. I think Glide can be used but I dont have any idea about that.
I followed the discussion on the QR Code Monkey Discussion
We need to set the “download” parameter to “imageUrl”, so that in the response we will get the url response for the QR .
We can simply load that url in the Glide by following snippets of code :
Glide.with(this).load(IMAGE_URL_FROM_RESPONSE).into(yourImageView);