capture Picture with Intent - Android android.graphics

Android examples for android.graphics:Picture

Description

capture Picture with Intent

Demo Code

import java.io.File;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;

public class Main {

  public static int REQUEST_CAPTURE_IMAGE = 1;

  public static void capturePicture(Context context, File file) {
    Intent intent = new Intent();
    intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
    ((Activity) context).startActivityForResult(intent, REQUEST_CAPTURE_IMAGE);
  }// ww  w  . j  a v a 2 s .  c  o  m

}

Related Tutorials