title: saved video doesn't appear in gallery
body: <p>I hope someone can help me with this problem.</p>
  
  <p>I have an app which enables the user to take a video (.mp4) or pick existing one. If taking a video, the video is saved to a public directory and I triggered the Android to scan the file to add it to media gallery.</p>
  
  <p><strong>Problem is</strong>, taking the video is working fine, I can preview the finished video just fine in my app. But this same video won't appear in media gallery and won't be accessible by other apps -except the FileManager-, even though other .mp4 in the same folder appear in the list just fine.</p>
  
  <p><strong>Further info</strong>: </p>
  
  <ul>
  <li>In FileManager app, The not-appearing files have icon video icon  while the appearing ones got a thumbnail. I can trigger these not-appearing files to be added to media gallery apps by cut and paste the files in FileManager app (so I believe is not due to files being corrupted). </li>
  <li>The scan code works fine for the my code that take images from existing camera app, it just won't work for the video ones...</li>
  </ul>
  
  <p>Is there any need for additional permission for this to work? I've added/asked/request permission for write and read from ext. storage and camera in my manifest and code.</p>
  
  <p>This below is how I take the Video and scan it into gallery : </p>
  
  <pre><code>private void takeVideo() {
      Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
  
      if (takeVideoIntent.resolveActivity(ctx.getPackageManager()) != null) {
  
          // Create the file where photo should go
          File mediaFile = null;
  
          try {
              mediaFile = getOutputMediaFile(ctx, MEDIA_TYPE_VIDEO);
  
          } catch (IOException ex) {
              Log.e("FragCamera", "takeVideo() : Error occurred while creating File." + ex);
          }
  
          if (mediaFile != null) {
              Uri mediaUri = Uri.fromFile(mediaFile);
  
              Log.d("FragCamera", "takeVideo() mediaUri: " + mediaUri);
  
              currMediaUri = mediaUri;
              currPhotoPath = mediaFile.getAbsolutePath();
              Log.d("FragCamera", "takeVideo() currPhotoPath: " + currPhotoPath);
  
              //make the new file available for other apps
              updateMediaGallery(mediaFile);
  
              MediaScannerConnection.scanFile(
                      ctx,
                      new String[]{currPhotoPath},
                      new String[]{"video/mp4"},
                      new MediaScannerConnection.OnScanCompletedListener() {
                          @Override
                          public void onScanCompleted(String path, Uri uri) {
                              Log.v("FragCameraScan",
                                      "file " + path + " was scanned seccessfully: " + uri);
                          }
                      });
  
              takeVideoIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mediaUri);
              this.startActivityForResult(takeVideoIntent, I_REQUEST_VIDEO_CAPTURE);
          }
  
      }
  }
  
  private void galleryAddPic(String filePath) {
      Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
      File f = new File(filePath);
      Uri contentUri = Uri.fromFile(f);
      mediaScanIntent.setData(contentUri);
      ctx.sendBroadcast(mediaScanIntent);
  }
  </code></pre>
  
  <p>Logcat value for each Log in the code above :</p>
  
  <pre><code> D/FragCamera: takeVideo() mediaUri: file:///storage/emulated/0/DCIM/Camera/VID_20161207_142021.mp4
   D/FragCamera: takeVideo() currPhotoPath: /storage/emulated/0/DCIM/Camera/VID_20161207_142021.mp4
   V/FragCameraScan: file /storage/emulated/0/DCIM/Camera/VID_20161207_142021.mp4 was scanned seccessfully: null
  </code></pre>