List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE
String ACTION_IMAGE_CAPTURE
To view the source code for android.provider MediaStore ACTION_IMAGE_CAPTURE.
Click Source Link
From source file:Main.java
public static void getPhotoFromCamera(Activity context, int requestCode, Uri imageUri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name context.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static void takePicture(Activity mActivity, String imagePath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (null != imagePath && !imagePath.isEmpty()) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(imagePath))); }//ww w . j a v a 2 s . c o m mActivity.startActivityForResult(intent, BBS_REQUEST_CAMERA); }
From source file:Main.java
/*** * Constructs an intent for capturing a photo and storing it in a temporary * file.// www . jav a 2 s . c om */ public static Intent getTakePickIntent(File f) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); return intent; }
From source file:Main.java
public static boolean hasCamera(Activity activity) { PackageManager packageManager = activity.getPackageManager(); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
/** * Returns true if the device has a camera application installed, false * otherwise./*from w w w . j a v a2s. com*/ */ public static boolean hasCameraApplication(Context ctx) { return isIntentAvailable(ctx, MediaStore.ACTION_IMAGE_CAPTURE); }
From source file:Main.java
public static void openCamera(Context context, int code) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues())); // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory() + imagePath))); ((Activity) context).startActivityForResult(intent, code); } else/*from w ww. j a va2 s. c o m*/ Toast.makeText(context, "no sdcard!", Toast.LENGTH_SHORT).show(); }
From source file:Main.java
public static boolean supportsExtraOutput(String intentAction) { if (Build.MANUFACTURER.equalsIgnoreCase("samsung") && (Build.MODEL.startsWith("GT-") || Build.MODEL.startsWith("SM-"))) { // Samsung *Galaxy Models* contain a Camera app that does not implement EXTRA_OUTPUT properly. // Either doesn't support it or have a different behavior than the specified (e.g. Copies the // media file to both the destination path in the uri and the default gallery path). return false; }// ww w . j a v a 2 s .c om if (MediaStore.ACTION_IMAGE_CAPTURE.equals(intentAction)) { // Nexus One and other devices must use EXTRA_OUTPUT due to a bug with the default mechanism. // http://thanksmister.com/2012/03/16/android_null_data_camera_intent/ return true; } else if (MediaStore.ACTION_VIDEO_CAPTURE.equals(intentAction)) { // Some older devices like the Nexus One for ACTION_VIDEO_CAPTURE, don't support it. Use only on >= ICS. // Also, make sure to use EXTRA_OUTPUT due to a bug in Android 4.3 and later if not using it. // https://code.google.com/p/android/issues/detail?id=57996 return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH); } else { // MediaStore.Audio.Media.RECORD_SOUND_ACTION return true; } }
From source file:Main.java
public static Intent capturePhoto(Uri output) { final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (output != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, output); }//from ww w . jav a 2s. c o m return intent; }
From source file:Main.java
public static void startCamera(Activity activity, int requestCode, File outPath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri uri = Uri.fromFile(outPath);//w ww . j a v a2 s . c o m intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); activity.startActivityForResult(intent, requestCode); }
From source file:Main.java
public static List<Intent> createTakePictureIntentList(@NonNull Context context, @NonNull Uri outputFileUri) { List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { String packageName = res.activityInfo.packageName; Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName);/*from w w w . jav a 2s . c o m*/ intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(intent); } return cameraIntents; }