onActivityResult in another class


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


TirarFotoPrincipal(context, IV_Clicado, String_Dados);


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

        imageView.setOnClickListener(new View.OnClickListener() {
            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(

                Intent Intent_Camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                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