title: the photo does not appear in the gallery
body: <p>I try to take and save photo in my app. 
  I  wrote in manifest the fileprovider and path for him:</p>
  
  <pre><code>&lt;provider
              android:name="android.support.v4.content.FileProvider"
              android:authorities="mypacage.fileprovider"
              android:exported="false"
              android:grantUriPermissions="true"&gt;
          &lt;meta-data
              android:name="android.support.FILE_PROVIDER_PATHS"
              android:resource="@xml/path" /&gt;
              &lt;/provider&gt;
  
  &lt;paths xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;files-path name="my_images"  path="images"/&gt;
  
  &lt;/paths&gt;
  </code></pre>
  
  <p>In my activity I call Fragment Dialog (cameraOrChoosePhoto Dialog) which have a button, next make intent for opening camera and other actions for create file for photo:: </p>
  
  <pre><code>@Override
      public void onClick(View v) {
          switch (v.getId()) {
              case R.id.dialog_camera:
                  Uri uri = generateUriPhoto();
                  if(uri!=null) {
                      Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                      cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                      cameraIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION |
                                                            Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
                      getActivity().startActivityForResult(cameraIntent, SubItemDetail.CAMERA_RESULT);
                  } else dismiss();
                  break;
              case R.id.dialog_choose_photo:
                  break;
          }
      }
  
      private Uri generateUriPhoto() {
          file = createNameFile(); 
          uri = null;
          if (file != null) {
                        String aut = getActivity().getPackageName()+".fileprovider";
                         uri = getUriForFile(getActivity(), aut, file);
  
                        getActivity().grantUriPermission(getActivity().getPackageName(), uri, 
                                                                                Intent.FLAG_GRANT_READ_URI_PERMISSION |
                                                                                  Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
          }
          return uri;
  
      }
  
      public File getFile() {
          return file;
      }
  
      public Uri getUri() {  //  onActivityResult
          return uri;
      }
  
      private File createNameFile() {
          directory = new File(getActivity().getFilesDir(), "images");
          if (!directory.exists()) {
              directory.mkdirs();
          }
          String name = "photo_" + System.currentTimeMillis();
          File file = null;
          try {
              file = File.createTempFile(
                      name,  /* prefix */
                      ".jpg",         /* suffix */
                      directory      /* directory */
              );
          } catch (IOException e) {
              e.printStackTrace();
              dismiss();
          }
          return file;
      }
  </code></pre>
  
  <p>Next on my activity:</p>
  
  <p>.........</p>
  
  <pre><code>private Uri uri
  
  @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          CameraOrChoosePhotoDialog cameraOrChoosePhotoDialog = (CameraOrChoosePhotoDialog)             getFragmentManager().findFragmentByTag("camera"); 
  
          uri = cameraOrChoosePhotoDialog.getUri();// get uri from dialogfargment
  
          if (resultCode == RESULT_OK) {
              if (requestCode == CAMERA_RESULT) {
  
                   image.setImageURI(uri);
                  addPicToGallery(); //  try  to put photo in gallery
  
                  cameraOrChoosePhotoDialog.dismiss();  // close dialog
              }
          }
      }
  
      private void addPicToGallery() {
  
          Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,uri)); 
          mediaScanIntent.setData(uri));
           sendBroadcast(mediaScanIntent);
  
  
      }
  </code></pre>
  
  <p>but the photo does not appear in the gallery</p>