Android: Camera usage, first run onActivityResult not called

When running my app in a newly reset simulator/phone the onActivityResult method is not called when taking the first photo. Somehow launching the camera intent seems to activate the built-in camera as launched from the camera app itself. During the subsequent runs everything seems right.

I guess it has something to do with the permissions. I do ask for permission to the camera (permission.CAMERA) and for the storage (permission.WRITE_EXTERNAL_STORAGE). Upon launching the camera in the first run, the camera ask for permission to users location: Asking for location and Tagging location.

From here I can keep taking pictures as if launched the camera from outside the app. Camera.

This is strange as I pass a URI for saving the image for own app only.

private void openOfflineCamera(){
    offlineCamUri = getUriForOfflineCam();
    Intent takePictureForOfflineUse = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureForOfflineUse.putExtra(MediaStore.EXTRA_OUTPUT, offlineCamUri);
    startActivityForResult(takePictureForOfflineUse, OFFLINE_CAMERA_PIC_REQUEST);
private Uri getUriForOfflineCam(){

    Uri uri;
    File photoFile = null;

    try {
        photoFile = FileManager.createImageFile(this);
    } catch (IOException ex) {

    if(photoFile != null){

    uri = FileProvider.getUriForFile(this,
            getApplicationContext().getPackageName() + ".provider",

    return uri;


And onActivityResult is never called. If I launch the camera (and accept/decline location service) first then open my app everything is just fine. Tested in API 22-26.

So, what did I miss?