Android examples for Intent:Take Picture
Create take Photo Intent
//package com.java2s; import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.net.Uri; import android.provider.MediaStore; public class Main { public static final int REQUEST_CODE_TAKE_PHOTO = 0xF1; public static Uri takePhoto(Activity activity) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE" ContentValues values = new ContentValues(); Uri photoUri = activity.getContentResolver().insert( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri); activity.startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); return photoUri; }/*from w w w . j av a2 s. c o m*/ public static Uri takePhoto(android.support.v4.app.Fragment fragment) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE" ContentValues values = new ContentValues(); Uri photoUri = fragment .getActivity() .getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri); fragment.startActivityForResult(intent, REQUEST_CODE_TAKE_PHOTO); return photoUri; } }