How to Create Google Lens Application in Android?

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
  
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
  
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.ml.vision.FirebaseVision;
import com.google.firebase.ml.vision.common.FirebaseVisionImage;
import com.google.firebase.ml.vision.label.FirebaseVisionImageLabel;
import com.google.firebase.ml.vision.label.FirebaseVisionImageLabeler;
  
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
  
import java.util.ArrayList;
import java.util.List;
  
public class MainActivity extends AppCompatActivity {
  
    static final int REQUEST_IMAGE_CAPTURE = 1;
      
    
    
    private ImageView img;
    private Button snap, searchResultsBtn;
    private Bitmap imageBitmap;
    private RecyclerView resultRV;
    private SearchResultsRVAdapter searchResultsRVAdapter;
    private ArrayList dataModalArrayList;
    private String title, link, displayed_link, snippet;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
          
        
        img = (ImageView) findViewById(R.id.image);
        snap = (Button) findViewById(R.id.snapbtn);
        searchResultsBtn = findViewById(R.id.idBtnSearchResuts);
        resultRV = findViewById(R.id.idRVSearchResults);
          
        
        dataModalArrayList = new ArrayList();
          
        
        searchResultsRVAdapter = new SearchResultsRVAdapter(dataModalArrayList, MainActivity.this);
          
        
        LinearLayoutManager manager = new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false);
          
        
        
        resultRV.setLayoutManager(manager);
        resultRV.setAdapter(searchResultsRVAdapter);
  
        
        snap.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                
                dispatchTakePictureIntent();
            }
        });
          
        
        searchResultsBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                
                getResults();
            }
        });
    }
  
    private void getResults() {
        
        
        FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(imageBitmap);
          
        
        
        FirebaseVisionImageLabeler labeler = FirebaseVision.getInstance().getOnDeviceImageLabeler();
          
        
        labeler.processImage(image).addOnSuccessListener(new OnSuccessListener() {
            @Override
            public void onSuccess(List firebaseVisionImageLabels) {
                String searchQuery = firebaseVisionImageLabels.get(0).getText();
                searchData(searchQuery);
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                
                Toast.makeText(MainActivity.this, “Fail to detect image..”, Toast.LENGTH_SHORT).show();
            }
        });
    }
  
    private void searchData(String searchQuery) {
        String apiKey = “Enter your API key here”;

          
        
        RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener() {
            @Override
            public void onResponse(JSONObject response) {
                try {
                    
                    JSONArray organicResultsArray = response.getJSONArray(“organic_results”);
                    for (int i = 0; i < organicResultsArray.length(); i++) {                         JSONObject organicObj = organicResultsArray.getJSONObject(i);                         if (organicObj.has("title")) {                             title = organicObj.getString("title");                         }                         if (organicObj.has("link")) {                             link = organicObj.getString("link");                         }                         if (organicObj.has("displayed_link")) {                             displayed_link = organicObj.getString("displayed_link");                         }                         if (organicObj.has("snippet")) {                             snippet = organicObj.getString("snippet");                         }                                                  dataModalArrayList.add(new DataModal(title, link, displayed_link, snippet));                     }                                                               searchResultsRVAdapter.notifyDataSetChanged();                 } catch (JSONException e) {                     e.printStackTrace();                 }             }         }, new Response.ErrorListener() {             @Override             public void onErrorResponse(VolleyError error) {                                  Toast.makeText(MainActivity.this, "No Result found for the search query..", Toast.LENGTH_SHORT).show();             }         });                  queue.add(jsonObjectRequest);     }             private void dispatchTakePictureIntent() {                  Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);         if (takePictureIntent.resolveActivity(getPackageManager()) != null) {                          startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);         }     }        @Override     protected void onActivityResult(int requestCode, int resultCode, Intent data) {         super.onActivityResult(requestCode, resultCode, data);                           if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {             Bundle extras = data.getExtras();             imageBitmap = (Bitmap) extras.get("data");                                       img.setImageBitmap(imageBitmap);         }     } }