How to Google reverse image search with Bitmap or Base64 Android Java

169 Views Asked by At

I have a Java class that acquires a picture using the camera. The result of the activity is a bitmap.

I need to pass the bitmap to Google image search using an http request.

Here's the piece of code that gets the bitmap:

public void onActivityResult(ActivityResult result) {
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
    Bundle bundle = result.getData().getExtras();
    Bitmap bitmap = (Bitmap) bundle.get("data");
    String base64 = encodeTobase64(bitmap);

    requestQueue = Volley.newRequestQueue(context);
    getRequest();
    postRequest(base64);
}
}

How do I implement a method to post a request to Google image search passing the bitmap as input?

Thank you.

0

There are 0 best solutions below