0

How to use onActivityResult inside a bottom sheet dialog class?

ivCaptureImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (new GlobalFunctions().CheckCameraPermission(activity))
                {
                    int CAMERA_REQUEST = 1000;
                    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                    activity.startActivityForResult(cameraIntent, CAMERA_REQUEST);
                }
            }
        });
Dinesh
  • 1,410
  • 2
  • 16
  • 29
SP Tutorials
  • 15
  • 2
  • 7
  • do you mean this https://stackoverflow.com/questions/5991319/capture-image-from-camera-and-display-in-activity ? – Jabal Logian Jul 08 '21 at 13:33
  • no,I am asking for bottom sheet not for activity – SP Tutorials Jul 09 '21 at 05:15
  • onActivityResult is the result of activity. If you started intent from dialog it will simply give the result in onActivityResult and you can do the job. Is there any special reason to still listen onActivityResult inside the dialog? – Muhammad Farhan Arif Jul 10 '21 at 06:21
  • @MuhammadFarhanArif yes,actually my dialog is opening from adapter,and inside dialog I have to capture image on button click,so how can i get this bitmap data on my dialog? – SP Tutorials Jul 10 '21 at 06:36
  • if you want to go with simple way, make objects of your dialogs at class level, means object of button, imageView etc should be declared where you are declaring other objects of that activity and initialize these objects inside dialog function. After that you will get result in onActivityResult of that activity and set image bitmap in this function easily – Muhammad Farhan Arif Jul 12 '21 at 05:15

0 Answers0