I created an example app, which takes pictures and saves them, by following [this tutorial](https://developer.android.com/training/camera/photobasics#java). Unfortunately the "Add the photo to a gallery" part is not working. I get no error in logcat. The image is just simply not visible in the gallery. Original code:

```
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(currentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
this.sendBroadcast(mediaScanIntent);

```

I tried to solve it, by calling `MediaScannerConnection.scanFile`:

```
MediaScannerConnection.scanFile(
    getApplicationContext(),
    new String[]{f.getAbsolutePath()},
    null,
    new MediaScannerConnection.OnScanCompletedListener() {
        @Override
        public void onScanCompleted(String path, Uri uri) {
            Log.v("MyActivity", "file " + path + " was scanned successfully: " + uri);
        }
    });

```

I get this result in logcat:

```
file /storage/emulated/0/Android/data/com.example.myapplication/files/Pictures/JPEG_20200804_104708_4760605263689075696.jpg was scanned successfully: content://media/external/file/3524

```

Unfortunately the picture is still not available in the gallery. What do I wrong? How is it possible to debug something like this?