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:org.gots.ui.NewSeedActivity.java
@Override public void onTakePicture(DialogFragment fragment) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, getCacheDir() + "_tmp"); startActivityForResult(cameraIntent, REQUEST_TAKE_PHOTO); }
From source file:com.interestfriend.activity.ChatActivity.java
/** * /*from w ww .j av a 2 s. c o m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD", 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), SharedUtils.getHXId() + 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.givon.anhao.activity.ChatActivity.java
/** * ?/*from ww w . jav a2 s .c o m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), AnhaoApplication.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:com.hx.hxchat.activity.ChatActivity.java
/** * ?//from w ww . ja v a 2s . c o m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), BaseApplication.getApplication().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:com.nanostuffs.yurdriver.fragment.RegisterFragment.java
private void takePhotoFromCamera() { Calendar cal = Calendar.getInstance(); File file = new File(Environment.getExternalStorageDirectory(), (cal.getTimeInMillis() + ".jpg")); if (!file.exists()) { try {/*from ww w . j av a 2 s. c o m*/ file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } else { file.delete(); try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } uri = Uri.fromFile(file); Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); registerActivity.startActivityForResult(cameraIntent, AndyConstants.TAKE_PHOTO, AndyConstants.REGISTER_FRAGMENT_TAG); }
From source file:com.lastsoft.plog.GamesFragment.java
public void captureBox(Game game) { theGame = game;//from ww w .ja v a 2 s.c o m try { InputMethodManager inputManager = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } catch (Exception ignored) { } Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(mActivity.getPackageManager()) != null) { // Create the File where the photo should go photoFile = null; try { photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File } // Continue only if the File was successfully created if (photoFile != null) { photoUri = Uri.fromFile(photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); startActivityForResult(takePictureIntent, 0); } } }
From source file:co.taqat.call.ChatFragment.java
private void pickImage() { List<Intent> cameraIntents = new ArrayList<Intent>(); Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name_with_date).replace("%s", String.valueOf(System.currentTimeMillis()))); imageToUploadUri = Uri.fromFile(file); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri); cameraIntents.add(captureIntent);/*w ww .j a v a2s.co m*/ Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); 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.erhuoapp.erhuo.activity.ChatActivity.java
/** * ?/*www. j a v a 2s . c o m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), ErHuoApplication.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:com.ccxt.whl.activity.ChatActivity.java
/** * ?/*from w ww . j a v a 2 s.c om*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; } // cameraFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.getInstance().getUserName() cameraFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.getInstance().getUser() + 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.wemolian.app.wml.ChatActivity.java
/** * ?// ww w . j a v a2 s . c om */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), WeMoLianApplication.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); }