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.sanparks.sanscan.WizardEntryActivity.java
private void takePhoto() { // We must specify a destination path for an image. final File photo = new File(Environment.getExternalStorageDirectory(), genPhotoFileName()); _imageUri = Uri.fromFile(photo);//from w w w. j av a 2 s . co m final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, _imageUri); startActivityForResult(intent, PickImageActivity.REQUEST_CODE_TAKE_PHOTO); }
From source file:com.remobile.camera.CameraLauncher.java
/** * Get image from photo library.// ww w.j av a2s. co m * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. * @param encodingType */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! // TODO: Images from kitkat filechooser not going into crop function public void getImage(int srcType, int returnType, int encodingType) { Intent intent = new Intent(); String title = GET_PICTURE; croppedUri = null; if (this.mediaType == PICTURE) { intent.setType("image/*"); if (this.allowEdit) { intent.setAction(Intent.ACTION_PICK); intent.putExtra("crop", "true"); if (targetWidth > 0) { intent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { intent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); } File photo = createCaptureFile(encodingType); croppedUri = Uri.fromFile(photo); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, croppedUri); } else { intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } else if (this.mediaType == ALLMEDIA) { // I wanted to make the type 'image/*, video/*' but this does not work on all versions // of android so I had to go with the wildcard search. intent.setType("*/*"); title = GET_All; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private void setupCameraButton(View parentView) { View cameraButton = parentView.findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_camera); cameraButton.setOnClickListener(new View.OnClickListener() { @Override//ww w.j a va 2 s . co m public void onClick(View view) { lookUri = UtilCamera .getDefaultLookFromCameraUri(getString(hku.fyp14017.blencode.R.string.default_look_name)); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); startActivityForResult(intent, REQUEST_TAKE_PICTURE); } }); }
From source file:com.android.cts.verifier.managedprovisioning.ByodHelperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { Log.w(TAG, "Restored state"); mOriginalSettings = savedInstanceState.getBundle(ORIGINAL_SETTINGS_NAME); } else {/*from www . ja v a 2 s . com*/ mOriginalSettings = new Bundle(); } mAdminReceiverComponent = new ComponentName(this, DeviceAdminTestReceiver.class.getName()); mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent intent = getIntent(); String action = intent.getAction(); Log.d(TAG, "ByodHelperActivity.onCreate: " + action); // we are explicitly started by {@link DeviceAdminTestReceiver} after a successful provisioning. if (action.equals(ACTION_PROFILE_PROVISIONED)) { // Jump back to CTS verifier with result. Intent response = new Intent(ACTION_PROFILE_OWNER_STATUS); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); startActivityInPrimary(response); // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_QUERY_PROFILE_OWNER)) { Intent response = new Intent(); response.putExtra(EXTRA_PROVISIONED, isProfileOwner()); setResult(RESULT_OK, response); // Request to delete work profile. } else if (action.equals(ACTION_REMOVE_MANAGED_PROFILE)) { if (isProfileOwner()) { Log.d(TAG, "Clearing cross profile intents"); mDevicePolicyManager.clearCrossProfileIntentFilters(mAdminReceiverComponent); mDevicePolicyManager.wipeData(0); showToast(R.string.provisioning_byod_profile_deleted); } } else if (action.equals(ACTION_INSTALL_APK)) { boolean allowNonMarket = intent.getBooleanExtra(EXTRA_ALLOW_NON_MARKET_APPS, false); boolean wasAllowed = getAllowNonMarket(); // Update permission to install non-market apps setAllowNonMarket(allowNonMarket); mOriginalSettings.putBoolean(INSTALL_NON_MARKET_APPS, wasAllowed); // Request to install a non-market application- easiest way is to reinstall ourself final Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE) .setData(Uri.parse("package:" + getPackageName())) .putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true).putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(installIntent, REQUEST_INSTALL_PACKAGE); // Not yet ready to finish- wait until the result comes back return; // Queried by CtsVerifier in the primary side using startActivityForResult. } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) { final boolean intentFiltersSetForManagedIntents = new IntentFiltersTestHelper(this) .checkCrossProfileIntentFilters(IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED); setResult(intentFiltersSetForManagedIntents ? RESULT_OK : RESULT_FAILED, null); } else if (action.equals(ACTION_CAPTURE_AND_CHECK_IMAGE)) { // We need the camera permission to send the image capture intent. grantCameraPermissionToSelf(); Intent captureImageIntent = getCaptureImageIntent(); Pair<File, Uri> pair = getTempUri("image.jpg"); mImageFile = pair.first; mImageUri = pair.second; captureImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri); if (captureImageIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureImageIntent, REQUEST_IMAGE_CAPTURE); } else { Log.e(TAG, "Capture image intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT) || action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITHOUT_EXTRA_OUTPUT)) { // We need the camera permission to send the video capture intent. grantCameraPermissionToSelf(); Intent captureVideoIntent = getCaptureVideoIntent(); int videoCaptureRequestId; if (action.equals(ACTION_CAPTURE_AND_CHECK_VIDEO_WITH_EXTRA_OUTPUT)) { mVideoUri = getTempUri("video.mp4").second; captureVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mVideoUri); videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITH_EXTRA_OUTPUT; } else { videoCaptureRequestId = REQUEST_VIDEO_CAPTURE_WITHOUT_EXTRA_OUTPUT; } if (captureVideoIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureVideoIntent, videoCaptureRequestId); } else { Log.e(TAG, "Capture video intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (action.equals(ACTION_CAPTURE_AND_CHECK_AUDIO)) { Intent captureAudioIntent = getCaptureAudioIntent(); if (captureAudioIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(captureAudioIntent, REQUEST_AUDIO_CAPTURE); } else { Log.e(TAG, "Capture audio intent could not be resolved in managed profile."); showToast(R.string.provisioning_byod_capture_media_error); finish(); } return; } else if (ACTION_KEYGUARD_DISABLED_FEATURES.equals(action)) { final int value = intent.getIntExtra(EXTRA_PARAMETER_1, DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE); mDevicePolicyManager.setKeyguardDisabledFeatures(mAdminReceiverComponent, value); } else if (ACTION_LOCKNOW.equals(action)) { mDevicePolicyManager.lockNow(); setResult(RESULT_OK); } else if (action.equals(ACTION_TEST_NFC_BEAM)) { Intent testNfcBeamIntent = new Intent(this, NfcTestActivity.class); testNfcBeamIntent.putExtras(intent); startActivity(testNfcBeamIntent); finish(); return; } else if (action.equals(ACTION_TEST_CROSS_PROFILE_INTENTS_DIALOG)) { sendIntentInsideChooser(new Intent(CrossProfileTestActivity.ACTION_CROSS_PROFILE_TO_PERSONAL)); } else if (action.equals(ACTION_TEST_APP_LINKING_DIALOG)) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), UserManager.ALLOW_PARENT_PROFILE_APP_LINKING); Intent toSend = new Intent(Intent.ACTION_VIEW); toSend.setData(Uri.parse("http://com.android.cts.verifier")); sendIntentInsideChooser(toSend); } else if (action.equals(ACTION_SET_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.addUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_CLEAR_USER_RESTRICTION)) { final String restriction = intent.getStringExtra(EXTRA_PARAMETER_1); if (restriction != null) { mDevicePolicyManager.clearUserRestriction(DeviceAdminTestReceiver.getReceiverComponentName(), restriction); } } else if (action.equals(ACTION_BYOD_SET_LOCATION_AND_CHECK_UPDATES)) { handleLocationAction(); return; } else if (action.equals(ACTION_NOTIFICATION)) { showNotification(Notification.VISIBILITY_PUBLIC); } else if (ACTION_NOTIFICATION_ON_LOCKSCREEN.equals(action)) { mDevicePolicyManager.lockNow(); showNotification(Notification.VISIBILITY_PRIVATE); } else if (ACTION_CLEAR_NOTIFICATION.equals(action)) { mNotificationManager.cancel(NOTIFICATION_ID); } else if (ACTION_TEST_SELECT_WORK_CHALLENGE.equals(action)) { mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, Color.BLUE); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, getResources().getString(R.string.provisioning_byod_confirm_work_credentials_header)); startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD)); } else if (ACTION_LAUNCH_CONFIRM_WORK_CREDENTIALS.equals(action)) { KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); Intent launchIntent = keyguardManager.createConfirmDeviceCredentialIntent(null, null); startActivity(launchIntent); } else if (ACTION_SET_ORGANIZATION_INFO.equals(action)) { if (intent.hasExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME)) { final String organizationName = intent .getStringExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_NAME); mDevicePolicyManager.setOrganizationName(mAdminReceiverComponent, organizationName); } final int organizationColor = intent.getIntExtra(OrganizationInfoTestActivity.EXTRA_ORGANIZATION_COLOR, mDevicePolicyManager.getOrganizationColor(mAdminReceiverComponent)); mDevicePolicyManager.setOrganizationColor(mAdminReceiverComponent, organizationColor); } else if (ACTION_TEST_PARENT_PROFILE_PASSWORD.equals(action)) { startActivity(new Intent(DevicePolicyManager.ACTION_SET_NEW_PARENT_PROFILE_PASSWORD)); } // This activity has no UI and is only used to respond to CtsVerifier in the primary side. finish(); }
From source file:com.salmannazir.filemanager.businesslogic.EventHandler.java
private void showNewImageCreateDialog(final Activity mContext, final String directory) { boolean wrapInScrollView = true; new MaterialDialog.Builder(mContext).title("Create New Image File") .customView(R.layout.new_image_layout, wrapInScrollView).positiveText("Capture Image") .negativeText("Cancel").onPositive(new MaterialDialog.SingleButtonCallback() { @Override/*from ww w. ja v a 2s . c o m*/ public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { // TODO Toast.makeText(mContext, "+ve Clicked", Toast.LENGTH_SHORT).show(); Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (cameraIntent.resolveActivity(mContext.getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { EditText imageNameEditText = (EditText) dialog.findViewById(R.id.image_name); photoFile = createImageFile(imageNameEditText.getText().toString(), directory); } catch (IOException ex) { // Error occurred while creating the File Log.i("MainActivity", "IOException"); } // Continue only if the File was successfully created if (photoFile != null) { cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); mContext.startActivityForResult(cameraIntent, Constants.CAMERA_REQUEST); } } } }).show(); }
From source file:com.wit.android.support.content.intent.ImageIntent.java
/** * Adds two default {@link com.wit.android.support.content.intent.ContentIntent.ContentProviderItem}s. * One for {@link #REQUEST_CODE_GALLERY} and second one for {@link #REQUEST_CODE_CAMERA}. *//*from w ww.ja v a2 s .co m*/ @Override public ImageIntent withDefaultProviders() { withProviders( new ContentProviderItem().name("Gallery").intent(createGalleryIntent()) .requestCode(REQUEST_CODE_GALLERY), mCameraProvider = new ContentProviderItem().name("Camera").intent(createCameraIntent()) .requestCode(REQUEST_CODE_CAMERA)); if (mUri != null) { mCameraProvider.intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); } return this; }
From source file:im.vector.activity.RoomActivity.java
/** * Launch the camera/*from ww w . j a v a 2 s.co m*/ */ private void launchCamera() { Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // the following is a fix for buggy 2.x devices Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, CAMERA_VALUE_TITLE + formatter.format(date)); // The Galaxy S not only requires the name of the file to output the image to, but will also not // set the mime type of the picture it just took (!!!). We assume that the Galaxy S takes image/jpegs // so the attachment uploader doesn't freak out about there being no mimetype in the content database. values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); Uri dummyUri = null; try { dummyUri = RoomActivity.this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); } catch (UnsupportedOperationException uoe) { Log.e(LOG_TAG, "Unable to insert camera URI into MediaStore.Images.Media.EXTERNAL_CONTENT_URI - no SD card? Attempting to insert into device storage."); try { dummyUri = RoomActivity.this.getContentResolver() .insert(MediaStore.Images.Media.INTERNAL_CONTENT_URI, values); } catch (Exception e) { Log.e(LOG_TAG, "Unable to insert camera URI into internal storage. Giving up. " + e); } } catch (Exception e) { Log.e(LOG_TAG, "Unable to insert camera URI into MediaStore.Images.Media.EXTERNAL_CONTENT_URI. " + e); } if (dummyUri != null) { captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, dummyUri); } // Store the dummy URI which will be set to a placeholder location. When all is lost on samsung devices, // this will point to the data we're looking for. // Because Activities tend to use a single MediaProvider for all their intents, this field will only be the // *latest* TAKE_PICTURE Uri. This is deemed acceptable as the normal flow is to create the intent then immediately // fire it, meaning onActivityResult/getUri will be the next thing called, not another createIntentFor. RoomActivity.this.mLatestTakePictureCameraUri = dummyUri == null ? null : dummyUri.toString(); startActivityForResult(captureIntent, TAKE_IMAGE); }
From source file:com.zhaojian.jolly.fragment.UserPhotosFragment.java
private void takePhoto() { if (null == mPhotoFile) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mPhotoFile = Utils.getCameraPhotoFile(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFile)); startActivityForResult(takePictureIntent, RESULT_CAMERA); }/* w w w . j a v a 2 s. co m*/ }
From source file:com.dycode.jepretstory.mediachooser.activity.BucketHomeFragmentActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemID = item.getItemId(); if (itemID == android.R.id.home) { materialMenu.animateTouch();/* www . j ava 2 s . c om*/ finish(); } else if (itemID == R.id.menuNext) { if (mSelectedImages.size() == 0 && mSelectedImages.size() == 0) { Toast.makeText(BucketHomeFragmentActivity.this, getString(R.string.plaese_select_file), Toast.LENGTH_SHORT).show(); } else { if (mSelectedVideos.size() > 0) { Intent videoIntent = new Intent(); videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER); //videoIntent.putStringArrayListExtra("list", mSelectedVideo); videoIntent.putParcelableArrayListExtra("selectedVideos", mSelectedVideos); setResult(RESULT_OK, videoIntent); sendBroadcast(videoIntent); } if (mSelectedImages.size() > 0) { Intent imageIntent = new Intent(); imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER); //imageIntent.putStringArrayListExtra("list", mSelectedImage); imageIntent.putParcelableArrayListExtra("selectedImages", mSelectedImages); setResult(RESULT_OK, imageIntent); sendBroadcast(imageIntent); } finish(); } } else if (itemID == R.id.menuCamera) { if (currentMediaMode == MediaType.VIDEO) { Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); // create a file to save the image fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO); //fileUri = getVideoInMediaStore(fileUri); // set the image file name intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024)); intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit); intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND); // start the image capture Intent startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE); } else { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // create a file to save the image fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE); // set the image file name intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // start the image capture Intent startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } } return super.onOptionsItemSelected(item); }
From source file:ca.ualberta.app.activity.CreateAnswerActivity.java
/** * Create a storage for the picture in the answer * // www .j av a 2s. c om * @param view * View passed to the activity to check which button was pressed. */ public void take_answer_pic(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Create a folder to store pictures String folder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp"; File folderF = new File(folder); if (!folderF.exists()) { folderF.mkdir(); } // Create an URI for the picture file String imageFilePath = folder + "/" + String.valueOf(System.currentTimeMillis()) + ".jpg"; File imageFile = new File(imageFilePath); imageFileUri = Uri.fromFile(imageFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri); startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }