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.grass.caishi.cc.activity.RegisterActivity.java
/** * ?/*from w w w . j a v a 2 s .c om*/ */ public void selectPicFromCamera() { // cameraFile = new File(PathUtil.getInstance().getImagePath(), // DemoApplication.getInstance().getUserName() startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), USERPIC_REQUEST_CODE_CAMERA); }
From source file:com.lcl6.cn.imagepickerl.AndroidImagePicker.java
/** * take picture/*from www. jav a 2 s . c o m*/ */ 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.silentcircle.contacts.detail.PhotoSelectionHandler19.java
/** * Constructs an intent for capturing a photo and storing it in a temporary output uri. */// w w w .jav a 2 s .c o m private Intent getTakePhotoIntent(Uri outputUri) { final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null); ContactPhotoUtils19.addPhotoPickerExtras(intent, outputUri); return intent; }
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();/*w w w . j av a 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:org.egov.android.view.activity.CreateComplaintActivity.java
/** * Function called when choosing the camera option. Start the implicit intent * ACTION_IMAGE_CAPTURE for result./*ww w. j av a2 s . c o m*/ */ private void _openCamera() { File imageFile = null; try { int photoNo = file_upload_limit + 1; imageFile = new File( assetPath + File.separator + "current" + File.separator + "photo_" + photoNo + ".jpg"); currentPhotoPath = imageFile.getAbsolutePath(); Intent mediaCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mediaCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); startActivityForResult(mediaCamera, CAPTURE_IMAGE); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.bf.zxd.zhuangxudai.my.fragment.CompanyApplyFragment.java
private void ChangeIcon() { //PopupWindow----START-----??PopupWindowPopupWindow??? backgroundAlpha(0.3f);// w w w.j av a2 s. co m View view = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.popu_window, null); final PopupWindow popupWindow = new PopupWindow(view, ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT, true); popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); popupWindow.setOutsideTouchable(true); popupWindow.setFocusable(true); //?? DisplayMetrics dm = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm); popupWindow.setWidth(dm.widthPixels); popupWindow.setAnimationStyle(R.style.popuwindow); //? popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0); popupWindow.setOnDismissListener(new poponDismissListener_CompanyApplyFragment()); //PopupWindow-----END //PopupWindow Button button = (Button) view.findViewById(R.id.take_photo);//?? Button button1 = (Button) view.findViewById(R.id.all_photo);//? Button button2 = (Button) view.findViewById(R.id.out);//? button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); } }); button1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,? Log.i("Daniel", "------"); allPhoto(); } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { backgroundAlpha(1f); popupWindow.dismiss(); //,Intent???? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //,?? File file = FileUitlity.getInstance(getActivity().getApplicationContext()).makeDir("head_image"); //?? path = file.getParent() + File.separatorChar + System.currentTimeMillis() + ".jpg"; //?IntentIntent? intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(path))); //? intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //?Intent??RoundImageView startActivityForResult(intent, REQUEST_CODE); } }); }
From source file:org.fs.galleon.presenters.ToolsFragmentPresenter.java
private void dispatchTakePictureIntent() { createIfNotExists().subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(file -> {/* w ww .j a v a 2s .com*/ if (file.exists()) { log(Log.INFO, String.format(Locale.ENGLISH, "%s is temp file.", file.getAbsolutePath())); } if (view.isAvailable()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(view.getContext().getPackageManager()) != null) { this.tempTakenPhoto = file;//set it in property Uri uri = FileProvider.getUriForFile(view.getContext(), GRANT_PERMISSION, file); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); //fileProvider requires gran permission to others access that uri if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { final Context context = view.getContext(); List<ResolveInfo> infos = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (infos != null) { StreamSupport.stream(infos).filter(x -> x.activityInfo != null) .map(x -> x.activityInfo.packageName).forEach(pack -> { context.grantUriPermission(pack, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); }); } } view.startActivityForResult(intent, REQUEST_TAKE_PHOTO); } else { view.showError("You need to install app that can capture photo."); } } }, this::log); }
From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Insurance.ReportAccident.java
private void cameraIntent() { // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // startActivityForResult(intent, REQUEST_CAMERA); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, "New Picture"); values.put(MediaStore.Images.Media.DESCRIPTION, "From your Camera"); imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); startActivityForResult(intent, REQUEST_CAMERA); }
From source file:net.jongrakko.zipsuri.activity.PostUploadActivity.java
private void takeImage() { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); takeFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Zisuri_tmp_" + System.currentTimeMillis() + ".jpg"); Uri saveUri = Uri.fromFile(takeFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, saveUri); // set the image file name startActivityForResult(intent, TAKE_PHOTO_FOR_AVATAR); }
From source file:com.app.sample.chatting.activity.chat.ChatActivity.java
private void goToCamera() { File file = null;// w ww . ja va 2s . c o m try { file = new File( Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "temp.jpg"); } catch (Exception e) { e.printStackTrace(); } Uri uri = Uri.fromFile(file); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.Images.Media.ORIENTATION, 0); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); this.startActivityForResult(intent, TAKE_PICTURE); /*// File file = new File(Environment.getExternalStorageDirectory(), "temp.jpg"); outputFileUri = Uri.fromFile(file); //?intent Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); //??? startActivityForResult(intent, TAKE_PICTURE);*/ }