List of usage examples for android.provider MediaStore EXTRA_OUTPUT
String EXTRA_OUTPUT
To view the source code for android.provider MediaStore EXTRA_OUTPUT.
Click Source Link
From source file:com.example.android.testing.notes.addnote.AddNoteFragment.java
@Override public void openCamera(String saveTo) { // Open the camera to take a picture. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Check if there is a camera app installed to handle our Intent if (takePictureIntent.resolveActivity(getContext().getPackageManager()) != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.parse(saveTo)); startActivityForResult(takePictureIntent, REQUEST_CODE_IMAGE_CAPTURE); } else {/* w w w .j a v a 2 s . c o m*/ Snackbar.make(mTitle, getString(R.string.cannot_connect_to_camera_message), Snackbar.LENGTH_SHORT) .show(); } }
From source file:co.mwater.foregroundcameraplugin.ForegroundCameraLauncher.java
/** * Take a picture with the camera. When an image is captured or the camera * view is cancelled, the result is returned in * CordovaActivity.onActivityResult, which forwards the result to * this.onActivityResult./*from w w w . ja v a 2s. c om*/ * * The image can either be returned as a base64 string or a URI that points * to the file. To display base64 string in an img tag, set the source to: * img.src="data:image/jpeg;base64,"+result; or to display URI in an img tag * img.src=result; * */ public void takePicture() { // Save the number of images currently on disk for later this.numPics = queryImgDB().getCount(); Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class); this.photo = createCaptureFile(); this.imageUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri); this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1); }
From source file:com.grottworkshop.gwswizardpager.ui.ImageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_page_image, container, false); ((TextView) rootView.findViewById(android.R.id.title)).setText(mPage.getTitle()); imageView = (ImageView) rootView.findViewById(R.id.imageView); String imageData = mPage.getData().getString(Page.SIMPLE_DATA_KEY); if (!TextUtils.isEmpty(imageData)) { Uri imageUri = Uri.parse(imageData); imageView.setImageURI(imageUri); } else {//from ww w . ja v a 2 s . co m imageView.setImageResource(R.drawable.ic_person); } imageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { DialogFragment pickPhotoSourceDialog = new DialogFragment() { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setItems(R.array.image_photo_sources, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: // Gallery Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, GALLERY_REQUEST_CODE); break; default: // Camera mNewImageUri = getActivity().getContentResolver().insert( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues()); Intent photoFromCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); photoFromCamera.putExtra(MediaStore.EXTRA_OUTPUT, mNewImageUri); photoFromCamera.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); startActivityForResult(photoFromCamera, CAMERA_REQUEST_CODE); break; } } }); return builder.create(); } }; pickPhotoSourceDialog.show(getFragmentManager(), "pickPhotoSourceDialog"); } }); return rootView; }
From source file:ch.hesso.master.sweetcity.activity.report.ReportActivity.java
private void initButtons() { capture.setOnClickListener(new View.OnClickListener() { @Override//from w w w .ja v a 2 s. com public void onClick(View v) { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, CameraPictureProvider.CONTENT_URI); startActivityForResult(cameraIntent, IntentTag.TAKE_PICTURE); } }); tagSelection.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent tagIntent = new Intent(getApplicationContext(), TagSelectionActivity.class); startActivityForResult(tagIntent, IntentTag.TAG_SELECTION); } }); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { submitReport(); } }); }
From source file:com.example.android.emojify.MainActivity.java
/** * Creates a temporary image file and captures a picture to store in it. *//* w ww . j av a 2 s. c om*/ private void launchCamera() { // Create the capture image intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the temporary File where the photo should go File photoFile = null; try { photoFile = BitmapUtils.createTempImageFile(this); } catch (IOException ex) { // Error occurred while creating the File ex.printStackTrace(); } // Continue only if the File was successfully created if (photoFile != null) { // Get the path of the temporary file mTempPhotoPath = photoFile.getAbsolutePath(); // Get the content URI for the image file Uri photoURI = FileProvider.getUriForFile(this, FILE_PROVIDER_AUTHORITY, photoFile); // Add the URI so the camera can store the image takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); // Launch the camera activity startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } } }
From source file:com.albedinsky.android.support.intent.ImageIntent.java
/** * Creates a new instance of Intent with {@link MediaStore#ACTION_IMAGE_CAPTURE} that can be used * to launch a camera app to capture a single image. * * @param outputUri If not {@code null}, it will be attached to intent as {@link MediaStore#EXTRA_OUTPUT}, * so when the result is received in for example {@link Activity#onActivityResult(int, int, Intent)}, * the <var>outputUri</var> will address to a file which contains the currently * captured image.//w w w . j a v a2 s .co m * @return New camera intent instance. * @see #createCameraIntent(File) */ @NonNull public static Intent createCameraIntent(@Nullable Uri outputUri) { final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (outputUri != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri); } return intent; }
From source file:com.microsoft.projectoxford.visionsample.helper.SelectImageActivity.java
public void takePhoto(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { // Save the photo taken to a temporary file. File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); try {//from ww w . j a v a 2 s . co m mFilePhotoTaken = File.createTempFile("IMG_", /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ ); // Create the File where the photo should go // Continue only if the File was successfully created if (mFilePhotoTaken != null) { mUriPhotoTaken = FileProvider.getUriForFile(this, "com.microsoft.projectoxford.visionsample.fileprovider", mFilePhotoTaken); intent.putExtra(MediaStore.EXTRA_OUTPUT, mUriPhotoTaken); // Finally start camera activity startActivityForResult(intent, REQUEST_TAKE_PHOTO); } } catch (IOException e) { setInfo(e.getMessage()); } } }
From source file:com.kbeanie.imagechooser.api.VideoChooserManager.java
private String captureVideoCurrent() throws ChooserException { checkDirectory();//from w w w. jav a 2 s.c o m try { Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); filePathOriginal = buildFilePathOriginal(foldername, "mp4"); intent.putExtra(MediaStore.EXTRA_OUTPUT, buildCaptureUri(filePathOriginal)); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new ChooserException(e); } return filePathOriginal; }
From source file:com.example.photoremark.MainActivity.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.takephoto: // ??sdcard String status = Environment.getExternalStorageState(); if (status.equals(Environment.MEDIA_MOUNTED)) { try { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); tempFile = String.valueOf(System.currentTimeMillis()) + ".jpg"; File f = new File(systemInfo.PATH_TEMP, tempFile); Uri u = Uri.fromFile(f); intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); intent.putExtra(MediaStore.EXTRA_OUTPUT, u); startActivityForResult(intent, RESULT_CAPTURE_IMAGE); } catch (ActivityNotFoundException e) { Toast.makeText(MainActivity.this, "", Toast.LENGTH_LONG).show(); }/*from www .j a v a 2 s . c om*/ } else { Toast.makeText(MainActivity.this, "?", Toast.LENGTH_LONG).show(); } break; case R.id.create_word_home: Intent intent = new Intent(this, VisitActivity.class); intent.putExtra(VisitActivity.EXTRA, VisitActivity.TO_HOME); startActivity(intent); break; case R.id.create_word_village: Intent intent1 = new Intent(this, VisitActivity.class); intent1.putExtra(VisitActivity.EXTRA, VisitActivity.TO_VILLAGE); startActivity(intent1); break; } }
From source file:net.coding.program.project.init.create.ProjectCreateFragment.java
private void camera() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = CameraPhotoUtil.getOutputMediaFileUri(); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); startActivityForResult(intent, RESULT_REQUEST_PHOTO); }