onActivityResult in another class

0

I am creating an app where I have several camera calls, and I would like to create a class to call the camera to use in the project, well, the activity call is being made with the activityforresult in this class, the photo is captured when returning the main activity, onativityresult in the capture the code

Main_Activity

 
TirarFotoPrincipal(context, IV_Clicado, String_Dados);

Camera_Class

public void TirarFotoPrincipal(final Context context, final ImageView imageView, final String Dados) {

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                final String nome_foto = "foto_olho_" + lado_do_olho + "_" + id_animal_prontuario + "_principal.jpg";
                final String imagem = Constante.LOCALPATH + nome_foto;

                String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + nome_foto;

                File Nova_Foto = new File(path);
                File file = new File(new File(Environment.getExternalStorageDirectory(), "myfolder"), nome_foto);


                String CAMERA_FP_AUTHORITY = "com.example.john.oftalmovet.fileprovider";



                    fileUri = FileProvider.getUriForFile(
                            context,
                            CAMERA_FP_AUTHORITY,
                            Nova_Foto);



                Intent Intent_Camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                Intent_Camera.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                Intent_Camera.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
                startActivityForResult(Intent_Camera, codigo_for_result);
            }
        });


    }

these two codes are working, but I'm having trouble adding onactivityresult,

I tried to put in the camera class but n returned the data, I also tried to put in the main activity but it did not work either

If I put the code of the camera class directly into main_activity and call the onactivityresult with what I need to do after capturing the photo, it works perfectly, however it will be rewritten in several other activities

Thank you for your help!

    
asked by anonymous 18.02.2018 / 17:49

0 answers