0

There is a class, Photo:

public class Photo {

    Uri mUri;
    Activity ac;

    public static final int PHOTO_INTENT_REQUEST_CODE = 100;

    Photo(Activity ac) {
        this.ac = ac;
    }

    boolean Photo_for_registration(){
        mUri = generateFileUri();
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri);
        ac.startActivityForResult(intent, PHOTO_INTENT_REQUEST_CODE);
        return true;
    }

    private Uri generateFileUri() {
        File newFile = new File(path.getPath() + File.separator + "profile" + ".jpg");
        return Uri.fromFile(newFile);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        // Get bundle
        Bundle extras = intent.getExtras();
        if (requestCode == PHOTO_INTENT_REQUEST_CODE) {
            Log.e("act", requestCode + " " + resultCode + " " + intent.toString());
            Log.d("я", "родился");
        }
    }
}

That is called from a fragment,

registered_photo = new Photo(getActivity());
registered_photo.Photo_for_registration();

when you call logs in onActivityResult fail.

If you shove all in a fragment of the logs, it works. And the class is not called.

As the cause of the class, or how can you get around that on another?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • try putting ur onActivityResult in ur Activity class... – Neha Tyagi Aug 20 '15 at 06:46
  • please post more code and log – Kishore Jethava Aug 20 '15 at 06:46
  • onActivityResult is a method defined on Activity and Fragment classes, and the normal use is overriding it in sub-classes of said classes. In your case your class Photo is neither an activity nor a fragment. Are you calling Photo.onActivityResult manually from somewhere? At least you cannot expect the system to call onActivityResult on any given class from which startActivityForResult was called, you need to handle onActivityResult in the Activity or Fragment currently resumed when startActivity was called. – JHH Aug 20 '15 at 06:53
  • "try putting ur onActivityResult in ur Activity class" - Nothing happens – user3162374 Aug 20 '15 at 07:05
  • "onActivityResult is a method defined on Activity and Fragment classes, and the normal use is overriding it in sub-classes of said classes. In your case your class Photo is neither an activity nor a fragment. Are you calling Photo.onActivityResult manually from somewhere? At least you cannot expect the system to call onActivityResult on any given class from which startActivityForResult was called, you need to handle onActivityResult in the Activity or Fragment currently resumed when startActivity was called." how to do it?? – user3162374 Aug 20 '15 at 07:07

0 Answers0