Add file photo to gallery after capture from camera or downloaded - Android android.hardware

Android examples for android.hardware:Camera

Description

Add file photo to gallery after capture from camera or downloaded

Demo Code

import java.io.File;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;

public class Main {

  /**// ww  w.j av  a2s . c  om
   * Add file photo to gallery after capture from camera or downloaded.
   *
   * @param context
   * @param file
   */
  public static void galleryAddPic(Context context, File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
  }

}

Related Tutorials