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:de.azapps.mirakel.main_activity.task_fragment.TaskFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { this.cabState = null; this.markedFiles = new LongSparseArray<>(); this.markedSubtasks = new LongSparseArray<>(); this.main = (MainActivity) getActivity(); View view;//w w w . j a v a 2 s . c o m this.updateThread = new Runnable() { @Override public void run() { TaskFragment.this.detailView.update(TaskFragment.this.task); } }; try { view = inflater.inflate(R.layout.task_fragment, container, false); } catch (final Exception e) { Log.w(TaskFragment.TAG, "Failed do inflate layout", e); return null; } this.detailView = (TaskDetailView) view.findViewById(R.id.task_fragment_view); this.detailView.setOnTaskChangedListner(new OnTaskChangedListner() { @Override public void onTaskChanged(final Task newTask) { if (TaskFragment.this.main.getTasksFragment() != null && TaskFragment.this.main.getListFragment() != null) { TaskFragment.this.main.getTasksFragment().updateList(); TaskFragment.this.main.getListFragment().update(); } } }); this.detailView.setOnSubtaskClick(new OnTaskClickListener() { @Override public void onTaskClick(final Task t) { TaskFragment.this.main.setCurrentTask(t); } }); this.detailView.setFragmentManager(new NeedFragmentManager() { @Override public FragmentManager getFragmentManager() { return TaskFragment.this.main.getSupportFragmentManager(); } }); if (MirakelCommonPreferences.useBtnCamera() && Helpers.isIntentAvailable(this.main, MediaStore.ACTION_IMAGE_CAPTURE)) { this.detailView.setAudioButtonClick(new View.OnClickListener() { @Override public void onClick(final View v) { TaskDialogHelpers.handleAudioRecord(getActivity(), TaskFragment.this.task, new ExecInterfaceWithTask() { @Override public void exec(final Task t) { update(t); } }); } }); this.detailView.setCameraButtonClick(new View.OnClickListener() { @Override public void onClick(final View v) { try { final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final Uri fileUri = FileUtils.getOutputMediaFileUri(FileUtils.MEDIA_TYPE_IMAGE); if (fileUri == null) { return; } TaskFragment.this.main.setFileUri(fileUri); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); getActivity().startActivityForResult(cameraIntent, MainActivity.RESULT_ADD_PICTURE); } catch (final ActivityNotFoundException a) { ErrorReporter.report(ErrorType.PHOTO_NO_CAMERA); } catch (final IOException e) { if (e.getMessage().equals(FileUtils.ERROR_NO_MEDIA_DIR)) { ErrorReporter.report(ErrorType.PHOTO_NO_MEDIA_DIRECTORY); } } } }); } if (this.task != null) { update(this.task); } this.detailView.setOnSubtaskMarked(new OnTaskMarkedListener() { @Override public void markTask(final View v, final Task t, final boolean marked) { if (t == null || TaskFragment.this.cabState != null && TaskFragment.this.cabState != ActionbarState.SUBTASK) { return; } if (marked) { TaskFragment.this.cabState = ActionbarState.SUBTASK; if (mActionMode == null) { main.startActionMode(mActionModeCallback); } v.setBackgroundColor(Helpers.getHighlightedColor(getActivity())); TaskFragment.this.markedSubtasks.put(t.getId(), t); } else { Log.d(TaskFragment.TAG, "not marked"); v.setBackgroundColor(getActivity().getResources().getColor(android.R.color.transparent)); TaskFragment.this.markedSubtasks.remove(t.getId()); if (TaskFragment.this.markedSubtasks.size() == 0 && mActionMode != null) { mActionMode.finish(); } } if (TaskFragment.this.mMenu != null) { final MenuItem item = TaskFragment.this.mMenu.findItem(R.id.edit_task); if (mActionMode != null && item != null) { item.setVisible(TaskFragment.this.markedSubtasks.size() == 1); } } } }); this.detailView.setOnFileMarked(new OnFileMarkedListener() { @Override public void markFile(final View v, final FileMirakel e, final boolean marked) { if (e == null || TaskFragment.this.cabState != null && TaskFragment.this.cabState != ActionbarState.FILE) { return; } if (marked) { TaskFragment.this.cabState = ActionbarState.FILE; if (mActionMode == null) { main.startActionMode(mActionModeCallback); } v.setBackgroundColor(Helpers.getHighlightedColor(getActivity())); TaskFragment.this.markedFiles.put(e.getId(), e); } else { v.setBackgroundColor(getActivity().getResources().getColor(android.R.color.transparent)); TaskFragment.this.markedFiles.remove(e.getId()); if (TaskFragment.this.markedFiles.size() == 0 && mActionMode != null) { mActionMode.finish(); } } } }); this.detailView.setOnFileClicked(new OnFileClickListener() { @Override public void clickOnFile(final FileMirakel file) { final Context context = getActivity(); String[] items; if (FileUtils.isAudio(file.getFileUri())) { items = context.getResources().getStringArray(R.array.audio_playback_options); } else { TaskDialogHelpers.openFile(context, file); return; } new AlertDialog.Builder(context).setTitle(R.string.audio_playback_select_title) .setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { switch (which) { case 0: // Open TaskDialogHelpers.openFile(context, file); break; default: // playback TaskDialogHelpers.playbackFile(getActivity(), file, which == 1); break; } } }).show(); return; } }); this.detailView.update(this.main.getCurrentTask()); return view; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private void setupGalleryButton(View parentView) { View galleryButton = parentView.findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_gallery); galleryButton.setOnClickListener(new View.OnClickListener() { @Override/*from w ww.j ava 2 s .c om*/ public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); startActivityForResult(intent, REQUEST_SELECT_IMAGE); } }); }
From source file:com.example.alyshia.customsimplelauncher.MainActivity.java
private void handlepicker() { View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT); Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight()); Display display = getWindowManager().getDefaultDisplay(); int aspect_x = content.getWidth(); int aspect_y = content.getHeight(); //enable gallary if disabled edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE); ApplicationPolicy appPolicy = edm.getApplicationPolicy(); boolean success = appPolicy.removePackagesFromPreventStartBlackList(gallery); if (success) { Log.d(TAG, "enabling back gallery successful"); Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType("image/*"); photoPickerIntent.putExtra("crop", "true"); photoPickerIntent.putExtra("aspectX", aspect_x); photoPickerIntent.putExtra("aspectY", aspect_y); photoPickerIntent.putExtra("outputX", aspect_x); photoPickerIntent.putExtra("outputY", aspect_y); photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri()); photoPickerIntent.putExtra("return-data", true); photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); startActivityForResult(photoPickerIntent, REQ_CODE_PICK_IMAGE); } else {//from w w w. ja v a2 s .c o m Log.d(TAG, "enabling back gallery UNsuccessful"); } }
From source file:com.pizidea.imagepicker.util.AndroidImagePicker.java
/** * take picture/*from ww w . j ava 2 s. com*/ */ public void takePicture(Fragment fragment, int requestCode) throws IOException { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA); takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(fragment.getContext().getPackageManager()) != null) { // Create the File where the photo should go //File photoFile = createImageFile(); File photoFile = createImageSaveFile(fragment.getContext()); // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); Log.i(TAG, "=====file ready to take photo:" + photoFile.getAbsolutePath()); } } fragment.startActivityForResult(takePictureIntent, requestCode); }
From source file:com.liwn.zzl.markbit.DrawOptionsMenuActivity.java
private void cropImage(Uri uri) { File file = FileIO.getFile(this, uri); Uri tmp = Uri.fromFile(file);//from ww w . j a va2 s .c o m Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(tmp, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", MarkBitApplication.BIT_LCD_WIDTH); intent.putExtra("outputY", MarkBitApplication.BIT_LCD_HEIGHT); intent.putExtra("scale", true); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra("noFaceDetection", true); intent.putExtra("return-data", false); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); startActivityForResult(intent, REQUEST_CODE_CROP); }
From source file:com.nextgis.ngm_clink_monitoring.fragments.ObjectStatusFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { MainActivity activity = (MainActivity) getActivity(); View view = inflater.inflate(R.layout.fragment_object_status, null); mLineName = (TextView) view.findViewById(R.id.line_name_st); mObjectNameCaption = (TextView) view.findViewById(R.id.object_name_caption_st); mObjectName = (TextView) view.findViewById(R.id.object_name_st); mCompleteStatusButton = (Button) view.findViewById(R.id.complete_status_st); mPhotoHintText = (TextView) view.findViewById(R.id.photo_hint_text_st); mMakePhotoButton = (Button) view.findViewById(R.id.btn_make_photo_st); mPhotoGallery = (RecyclerView) view.findViewById(R.id.photo_gallery_st); registerForContextMenu(mPhotoGallery); String toolbarTitle = ""; switch (mFoclStructLayerType) { case FoclConstants.LAYERTYPE_FOCL_OPTICAL_CABLE: toolbarTitle = activity.getString(R.string.cable_laying); mObjectNameCaption.setText(R.string.optical_cable_colon); break;//from w ww .j av a 2s .c om case FoclConstants.LAYERTYPE_FOCL_FOSC: toolbarTitle = activity.getString(R.string.fosc_mounting); mObjectNameCaption.setText(R.string.fosc_colon); break; case FoclConstants.LAYERTYPE_FOCL_OPTICAL_CROSS: toolbarTitle = activity.getString(R.string.cross_mounting); mObjectNameCaption.setText(R.string.cross_colon); break; case FoclConstants.LAYERTYPE_FOCL_ACCESS_POINT: toolbarTitle = activity.getString(R.string.access_point_mounting); mObjectNameCaption.setText(R.string.access_point_colon); break; case FoclConstants.LAYERTYPE_FOCL_SPECIAL_TRANSITION: toolbarTitle = activity.getString(R.string.special_transition_laying); break; } activity.setBarsView(toolbarTitle); mCompleteStatusButton.setText(activity.getString(R.string.completed)); mPhotoHintText.setText(R.string.take_photos_to_confirm); final GISApplication app = (GISApplication) getActivity().getApplication(); final FoclProject foclProject = app.getFoclProject(); if (null == foclProject) { setBlockedView(); return view; } FoclStruct foclStruct; try { foclStruct = (FoclStruct) foclProject.getLayer(mLineId); } catch (Exception e) { foclStruct = null; } if (null == foclStruct) { setBlockedView(); return view; } FoclVectorLayer layer = (FoclVectorLayer) foclStruct.getLayerByFoclType(mFoclStructLayerType); if (null == layer) { setBlockedView(); return view; } if (null == mObjectId) { setBlockedView(); return view; } mLineName.setText(Html.fromHtml(foclStruct.getHtmlFormattedNameTwoStringsSmall())); mObjectLayerName = layer.getPath().getName(); Uri uri = Uri .parse("content://" + FoclSettingsConstantsUI.AUTHORITY + "/" + mObjectLayerName + "/" + mObjectId); String proj[] = { FIELD_ID, FoclConstants.FIELD_NAME, FoclConstants.FIELD_STATUS_BUILT }; Cursor objectCursor; try { objectCursor = getActivity().getContentResolver().query(uri, proj, null, null, null); } catch (Exception e) { Log.d(TAG, e.getLocalizedMessage()); objectCursor = null; } boolean blockView = false; if (null != objectCursor) { try { if (objectCursor.getCount() == 1 && objectCursor.moveToFirst()) { String objectNameText = ObjectCursorAdapter.getObjectName(mContext, objectCursor); mObjectStatus = objectCursor .getString(objectCursor.getColumnIndex(FoclConstants.FIELD_STATUS_BUILT)); if (TextUtils.isEmpty(mObjectStatus)) { mObjectStatus = FoclConstants.FIELD_VALUE_UNKNOWN; } mObjectName.setText(objectNameText); setStatusButtonView(true); } else { blockView = true; } } catch (Exception e) { blockView = true; //Log.d(TAG, e.getLocalizedMessage()); } finally { objectCursor.close(); } } else { blockView = true; } if (blockView) { setBlockedView(); return view; } View.OnClickListener statusButtonOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (mObjectStatus) { case FoclConstants.FIELD_VALUE_PROJECT: mObjectStatus = FoclConstants.FIELD_VALUE_BUILT; break; case FoclConstants.FIELD_VALUE_BUILT: mObjectStatus = FoclConstants.FIELD_VALUE_PROJECT; break; case FoclConstants.FIELD_VALUE_UNKNOWN: default: mObjectStatus = FoclConstants.FIELD_VALUE_BUILT; break; } Uri uri = Uri.parse("content://" + FoclSettingsConstantsUI.AUTHORITY + "/" + mObjectLayerName); Uri updateUri = ContentUris.withAppendedId(uri, mObjectId); ContentValues values = new ContentValues(); Calendar calendar = Calendar.getInstance(); values.put(FoclConstants.FIELD_STATUS_BUILT, mObjectStatus); values.put(FoclConstants.FIELD_STATUS_BUILT_CH, calendar.getTimeInMillis()); int result = 0; try { result = getActivity().getContentResolver().update(updateUri, values, null, null); } catch (Exception e) { Log.d(TAG, e.getLocalizedMessage()); } if (result == 0) { Log.d(TAG, "Layer: " + mObjectLayerName + ", id: " + mObjectId + ", update FAILED"); } else { Log.d(TAG, "Layer: " + mObjectLayerName + ", id: " + mObjectId + ", update result: " + result); setStatusButtonView(true); } } }; ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { View customActionBarView = actionBar.getCustomView(); View saveMenuItem = customActionBarView.findViewById(R.id.custom_toolbar_button_layout); saveMenuItem.setOnClickListener(statusButtonOnClickListener); // TODO: it is test } mCompleteStatusButton.setOnClickListener(statusButtonOnClickListener); mMakePhotoButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (null != cameraIntent.resolveActivity(getActivity().getPackageManager())) { try { File tempFile = new File(app.getDataDir(), "temp-photo.jpg"); if (!tempFile.exists() && tempFile.createNewFile() || tempFile.exists() && tempFile.delete() && tempFile.createNewFile()) { mTempPhotoPath = tempFile.getAbsolutePath(); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile)); startActivityForResult(cameraIntent, REQUEST_TAKE_PHOTO); } } catch (IOException e) { Toast.makeText(getActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show(); } } } }); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false); mPhotoGallery.setLayoutManager(layoutManager); mPhotoGallery.setHasFixedSize(true); setPhotoGalleryAdapter(); setPhotoGalleryVisibility(true); return view; }
From source file:com.snappy.CameraCropActivity.java
public void startCamera() { // Check if camera exists if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { Toast.makeText(this, R.string.no_camera, Toast.LENGTH_LONG).show(); finish();//from ww w . j av a2 s .co m } else { try { long date = System.currentTimeMillis(); String filename = DateFormat.format("yyyy-MM-dd_kk.mm.ss", date).toString() + ".jpg"; _path = this.getExternalCacheDir() + "/" + filename; File file = new File(_path); // File file = new File(getFileDir(getBaseContext()), filename); Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, CAMERA); } catch (Exception ex) { Toast.makeText(this, R.string.no_camera, Toast.LENGTH_LONG).show(); finish(); } } }
From source file:com.team.formal.eyeshopping.MainActivity.java
public void startCamera() { if (PermissionUtils.requestPermission(this, CAMERA_PERMISSIONS_REQUEST, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri photoUri = FileProvider.getUriForFile(getApplicationContext(), getApplicationContext().getPackageName() + ".provider", getCameraFile()); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivityForResult(intent, CAMERA_IMAGE_REQUEST); }//from w w w . j a v a 2 s. co m }
From source file:com.concavenp.artistrymuse.ImageAppCompatActivity.java
protected void dispatchTakePictureIntent() { 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 File where the photo should go File photoFile = createImageFile(); // Continue only if the File was successfully created if (photoFile != null) { Uri photoURI = FileProvider.getUriForFile(this, "com.concavenp.artistrymuse", photoFile); Log.d(TAG, "New camera image URI location: " + photoURI.toString()); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); }// w ww . j a va 2 s.c om } }
From source file:com.silentcircle.contacts.detail.PhotoSelectionHandler.java
/** * Constructs an intent for capturing a photo and storing it in a temporary file. *///from w ww . j a va 2 s.c o m private static Intent getTakePhotoIntent(String fileName) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); final String newPhotoPath = ContactPhotoUtils.pathForNewCameraPhoto(fileName); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(newPhotoPath))); return intent; }