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 Intent getImageFromGalleryCamera(Context context) { // Determine Uri of camera image to save. File root = new File( Environment.getExternalStorageDirectory() + File.separator + "dianta/camera" + File.separator); root.mkdirs();//from ww w . j av a 2s . co m String fname = "dianta-" + System.currentTimeMillis() + ".jpg"; File sdImageMainDirectory = new File(root, fname); Uri outputFileUri = Uri.fromFile(sdImageMainDirectory); // camera List<Intent> cameraIntents = new ArrayList<>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager lPackageManager = context.getPackageManager(); List<ResolveInfo> listCam = lPackageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo rInfo : listCam) { String packageName = rInfo.activityInfo.packageName; Intent lIntent = new Intent(captureIntent); lIntent.setComponent(new ComponentName(rInfo.activityInfo.packageName, rInfo.activityInfo.name)); lIntent.setPackage(packageName); //save camera result to external storage lIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); cameraIntents.add(lIntent); } //ugly hacks for camera helper lastCameraImageSaved = outputFileUri; // gallery Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); Intent chooserIntent = Intent.createChooser(galleryIntent, "Pilih Sumber"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[cameraIntents.size()])); return chooserIntent; }
From source file:com.todoroo.astrid.actfm.ActFmCameraModule.java
public static void showPictureLauncher(final Activity activity, final ClearImageCallback clearImageOption) { ArrayList<String> options = new ArrayList<String>(); final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager pm = activity.getPackageManager(); final boolean cameraAvailable = pm.queryIntentActivities(cameraIntent, 0).size() > 0; if (cameraAvailable) options.add(activity.getString(R.string.actfm_picture_camera)); options.add(activity.getString(R.string.actfm_picture_gallery)); if (clearImageOption != null) options.add(activity.getString(R.string.actfm_picture_clear)); ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity, android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()])); DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @SuppressWarnings("nls") @Override/*from w ww . jav a2 s .c o m*/ public void onClick(DialogInterface d, int which) { if (which == 0 && cameraAvailable) { lastTempFile = getTempFile(activity); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (lastTempFile != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile)); } activity.startActivityForResult(intent, REQUEST_CODE_CAMERA); } else if ((which == 1 && cameraAvailable) || (which == 0 && !cameraAvailable)) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); activity.startActivityForResult( Intent.createChooser(intent, activity.getString(R.string.actfm_TVA_tag_picture)), REQUEST_CODE_PICTURE); } else { if (clearImageOption != null) clearImageOption.clearImage(); } } }; // show a menu of available options new AlertDialog.Builder(activity).setAdapter(adapter, listener).show().setOwnerActivity(activity); }
From source file:com.yanzhenjie.album.util.AlbumUtils.java
/** * Start the camera.//w ww. jav a 2s .c o m * * @param fragment fragment. * @param requestCode code. * @param outPath file path. */ public static void startCamera(Fragment fragment, int requestCode, File outPath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri uri = getUri(fragment.getContext(), outPath); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); fragment.startActivityForResult(intent, requestCode); }
From source file:com.yanzhenjie.album.util.AlbumUtils.java
/** * Start the camera./*w ww .j a v a 2s .c o m*/ * * @param fragment fragment. * @param requestCode code. * @param outPath file path. */ public static void startCamera(android.app.Fragment fragment, int requestCode, File outPath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri uri = getUri(fragment.getActivity(), outPath); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); fragment.startActivityForResult(intent, requestCode); }
From source file:MainActivity.java
public void takePicture(View view) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { mLastPhotoURI = createFileURI(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mLastPhotoURI); startActivityForResult(takePictureIntent, PHOTO_RESULT); }/*from w w w. j a va 2s. c o m*/ }
From source file:disono.webmons.com.utilities.sensor.Camera.Launcher.java
public void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(mActivity.getApplicationContext().getPackageManager()) != null) { mActivity.startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); }//from ww w . ja v a2s . c o m }
From source file:Main.java
/** * Returns an intent calling the android chooser. The chooser will provide apps, which listen to one of the following actions * {@link Intent#ACTION_GET_CONTENT} , {@link MediaStore#ACTION_IMAGE_CAPTURE}, {@link MediaStore#ACTION_VIDEO_CAPTURE}, * {@link MediaStore.Audio.Media#RECORD_SOUND_ACTION} * //from w w w .ja va 2 s.co m * @return Intent that opens the app chooser. */ public static Intent getChooserIntent() { // GET_CONTENT Apps Intent getContentIntent = new Intent(); getContentIntent.setAction(Intent.ACTION_GET_CONTENT); getContentIntent.setType("*/*"); getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); // ACTION_IMAGE_CAPTURE Apps Intent captureImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // ACTION_VIDEO_CAPTURE Apps Intent captureVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // RECORD_SOUND_ACTION Apps Intent recordSoungIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION); Intent finalIntent = Intent.createChooser(getContentIntent, "test"); finalIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { captureImageIntent, captureVideoIntent, recordSoungIntent }); return finalIntent; }
From source file:de.baumann.quitsmoking.helper.Popup_camera.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Toast.makeText(Popup_camera.this, R.string.cam_start, Toast.LENGTH_LONG).show(); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File f = helper_main.newFile(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Uri contentUri = FileProvider.getUriForFile(Popup_camera.this, getApplicationContext().getPackageName() + ".provider", f); intent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); } else {/*from w ww . java 2 s .c om*/ intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); } try { startActivityForResult(intent, 1); finish(); } catch (ActivityNotFoundException e) { Toast.makeText(Popup_camera.this, R.string.cam_fail, Toast.LENGTH_SHORT).show(); } }
From source file:info.guardianproject.iocipher.camera.StillCameraActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mFileBasePath = getIntent().getStringExtra("basepath"); isRequest = getIntent().getAction() != null && getIntent().getAction().equals(MediaStore.ACTION_IMAGE_CAPTURE); mResultList = new ArrayList<String>(); button.setBackgroundResource(R.drawable.ic_action_camera); buttonSelfie.setBackgroundResource(R.drawable.ic_action_switch_camera); }
From source file:disono.webmons.com.utilities.sensor.Camera.Launcher.java
public void takePicture(FragmentActivity fragmentActivity) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(mActivity.getApplicationContext().getPackageManager()) != null) { fragmentActivity.startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); }//from w w w . jav a2 s . co m }