Create Intent to capture Picture - Android Intent

Android examples for Intent:Take Picture

Description

Create Intent to capture Picture

Demo Code


//package com.java2s;
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);/*from  www.j av a 2 s.c  om*/
    }
}

Related Tutorials