Override method onActivityResult is never called

Yan

New member
Dec 2, 2023
1
0
1
Visit site
Hello everyone!

I'm developing a feature to save picture with mobile camera and I have a problem with override method onActivityResult(), it is never called:

Java:
private void checkPermissionAndOpenCamera(Activity activity)
    {
        if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)
        {
            ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CAMERA}, 100);

            return;
        }

        openCamera();

    }

    private void openCamera() {
        //startActivityForResult(intent, IMAGE_CAPTURE_RESULT);

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, IMAGE_CAPTURE_RESULT);

    }



    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data)
    {
        super.onActivityResult(requestCode, resultCode, data);

        Toast.makeText(getActivity(), "ENTROU EM RESULT FUNCTION", Toast.LENGTH_LONG).show();
        
        if (resultCode == RESULT_OK)
        {
            Toast.makeText(getActivity(), "Picture!", Toast.LENGTH_LONG).show();
        }
    }

My class extends AppCompatDialogFragment.
 

Trending Posts

Forum statistics

Threads
941,601
Messages
6,909,591
Members
3,157,981
Latest member
TCone