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:com.ysls.imhere.ChatActivity.java
/** * ?//from www.j a va2s. c om */ public void selectPicFromCamera() { cameraFile = new File(PathUtil.getInstance().getImagePath(), MyApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg"); cameraFile.getParentFile().mkdirs(); startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA); }
From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java
public void updateButtons() { // a) Android 2.3 dosen't support speech toText // b) The user can switch off the button if (this.view == null) { return;//from w ww .ja va2 s . co m } if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.HONEYCOMB || !MirakelCommonPreferences.useBtnSpeak()) { this.view.findViewById(R.id.btnSpeak_tasks).setVisibility(View.GONE); } else { final ImageButton btnSpeak = (ImageButton) this.view.findViewById(R.id.btnSpeak_tasks); // txtText = newTask; btnSpeak.setVisibility(View.VISIBLE); btnSpeak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, TasksFragment.this.main.getString(R.string.speak_lang_code)); try { getActivity().startActivityForResult(intent, MainActivity.RESULT_SPEECH); TasksFragment.this.newTask.setText(""); } catch (final ActivityNotFoundException a) { ErrorReporter.report(ErrorType.NO_SPEACH_RECOGNITION); } } }); } if (!MirakelCommonPreferences.useBtnAudioRecord()) { this.view.findViewById(R.id.btnAudio_tasks).setVisibility(View.GONE); } else { final ImageButton btnAudio = (ImageButton) this.view.findViewById(R.id.btnAudio_tasks); btnAudio.setVisibility(View.VISIBLE); btnAudio.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { // TODO BAHHHH this is ugly! final Task task = Task.getDummy(getActivity(), TasksFragment.this.main.getCurrentList()); TaskDialogHelpers.handleAudioRecord(TasksFragment.this.main, task, new ExecInterfaceWithTask() { @Override public void exec(final Task t) { TasksFragment.this.main.setCurrentList(t.getList()); TasksFragment.this.main.setCurrentTask(t, true); } }); } }); } if (!MirakelCommonPreferences.useBtnCamera() || !Helpers.isIntentAvailable(this.main, MediaStore.ACTION_IMAGE_CAPTURE)) { this.view.findViewById(R.id.btnCamera).setVisibility(View.GONE); } else { final ImageButton btnCamera = (ImageButton) this.view.findViewById(R.id.btnCamera); btnCamera.setVisibility(View.VISIBLE); btnCamera.setOnClickListener(new 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; } TasksFragment.this.main.setFileUri(fileUri); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); getActivity().startActivityForResult(cameraIntent, MainActivity.RESULT_CAMERA); } 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); } } } }); } }
From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java
private void openCameraApplication() { Intent picIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (picIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(picIntent, CAMERA_REQUEST); }/*from ww w.j a va 2 s . c om*/ }
From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java
private void takePicture(int type, int RequestCode) { // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File tmpFile = null;/*w ww .j a va 2 s .c o m*/ try { tmpFile = File.createTempFile("capture", ".tmp"); } catch (IOException e) { e.printStackTrace(); } Intent camIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); uriOfPicFromCamera = Uri.fromFile(tmpFile); camIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriOfPicFromCamera); Intent gallIntent = new Intent(); gallIntent.setType("image/*"); gallIntent.setAction(Intent.ACTION_GET_CONTENT); if (type == 0) { ReportDetailsActivity.this.startActivityForResult(camIntent, RequestCode); } else if (type == 1) { ReportDetailsActivity.this.startActivityForResult(Intent.createChooser(gallIntent, "Galerie photo"), RequestCode); } // startActivityForResult(intent, v.getId()); }
From source file:com.just.agentweb.AgentWebUtils.java
static Intent getIntentCaptureCompat(Context context, File file) { Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri mUri = getUriFromFile(context, file); mIntent.addCategory(Intent.CATEGORY_DEFAULT); mIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); return mIntent; }
From source file:com.sim2dial.dialer.ChatFragment.java
private void pickImage() { final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name)); imageToUploadUri = Uri.fromFile(file); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri); cameraIntents.add(captureIntent);// w w w .j a va 2s .c o m final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, ADD_PHOTO); }
From source file:com.indoorsy.frash.easemob.activity.ChatActivity.java
/** * ?/*from w w w .j av a2 s . com*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { ToastUtil.toast(getApplicationContext(), R.string.sd_not_find); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), System.currentTimeMillis() + ".jpg"); cameraFile.getParentFile().mkdirs(); startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA); }
From source file:com.example.bidisha.ace.ClueScan.java
private void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File photo = new File(Environment.getExternalStorageDirectory(), "picture1.jpg"); // imageUri = Uri.fromFile(photo); imageUri = FileProvider.getUriForFile(ClueScan.this, BuildConfig.APPLICATION_ID + ".provider", photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, PHOTO_REQUEST); }
From source file:com.bai.android.ui.OtherActivity.java
public void changeAvatar() { // Prompt the user to select image from gallery or camera. alertDialog = new AlertDialog.Builder(OtherActivity.this); alertDialog.setMessage(getResources().getString(R.string.select_image_source)); alertDialog.setPositiveButton(getResources().getString(R.string.gallery), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // remove the dialog to prevent "leakage" dialog.dismiss();//from w ww . j a v a2s.com Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); intent.setType("image/*"); startActivityForResult(intent, GALLERY_IMAGE_ACTIVITY_REQUEST_CODE); } }); alertDialog.setNeutralButton(getResources().getString(R.string.camera), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Uri imageUri = getOutputMediaFileUri(); // create a file to save the image if (imageUri != null) { SharedPreferences.Editor prefEditor = getSharedPreferences(SHR_PRF_APP_KEY, MODE_PRIVATE).edit(); prefEditor.putString(SHR_PRF_IMG_URI, imageUri.getPath()); prefEditor.commit(); prefEditor = null; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name // start the image capture Intent startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } } }); alertDialog.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // close this dialog dialog.dismiss(); } }); alertDialog.show(); }
From source file:edu.sfsu.csc780.chathub.ui.MainActivity.java
private void dispatchTakePhotoIntent() { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager packageManager = getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(cameraIntent, 0); boolean isIntentSafe = activities.size() > 0; featureFlag = 1;//from w w w .ja v a 2 s. co m if (isIntentSafe) { startActivityForResult(cameraIntent, REQUEST_IMAGE_CAPTURE); } }