• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps onRequestPermissionResulti in fragment

RioLeal

Newbie
Is there anyone who knows how to make the onRequestPermissionResult method works from a fragment after click in camera?

I have a code for this, inside a fragment, and the camera is displaying correctly, but when I click to get a photo, this method does not is called.
 
After beating up my head on the wall, I found the answer:
Inside the Fragment, I insert this code to Intent to call the camera:

Java:
Intent intent = new Intent(MediaStore.Action_IMAGE_CAPTURE);
// The number 1, below, is my code for camera
getActivity().startActivityForResult(intent, 1);

And into MainActivity (which fragment belongs), I insert the code below:

Java:
public void onActivityResult(int requestCode, int requestResult, @Nullable Intent data){
    super.onActivityResult(requestCode, requestResult, data);
    int result = requestCode;
}

I'll feel me so glad if this code could help someone else, because, in the Internet, help is so hard.
 
Back
Top Bottom