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.qjdchina.qjdsale.MemberPicturePlusFragment.java
private void startCamera(String folder, String file) { if (Utils.isHasSdcard()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File imgFolder = new File(folder); if (!imgFolder.exists()) { imgFolder.mkdirs();/*w w w . j a va2s . co m*/ } File imgFile = new File(folder, file); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imgFile)); startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); } else { Toast.makeText(getActivity(), "SD?", Toast.LENGTH_SHORT).show(); } }
From source file:com.android.settings.users.EditUserPhotoController.java
private boolean canTakePhoto() { return mImageView.getContext().getPackageManager().queryIntentActivities( new Intent(MediaStore.ACTION_IMAGE_CAPTURE), PackageManager.MATCH_DEFAULT_ONLY).size() > 0; }
From source file:com.example.d062654.faciliman._2_IncidentPicture.java
private void captureImage() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (intent.resolveActivity(ll.getContext().getPackageManager()) != null) { // Create the File where the photo should go try {/*from ww w. j ava 2s . co m*/ photoFile = createImageFile(); } catch (IOException ex) { // Error occurred while creating the File } // Continue only if the File was successfully created if (photoFile != null) { Uri photoURI = FileProvider.getUriForFile(ll.getContext(), "com.d062654.fileprovider", photoFile); intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } } }
From source file:com.amytech.android.library.views.imagechooser.api.ImageChooserManager.java
private String takePicture() throws Exception { checkDirectory();/*from w w w.jav a 2 s . com*/ try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); filePathOriginal = FileUtils.getDirectory(foldername) + File.separator + Calendar.getInstance().getTimeInMillis() + ".jpg"; intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePathOriginal))); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new Exception("Activity not found"); } return filePathOriginal; }
From source file:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
private String takePicture() throws ChooserException { checkDirectory();/*from w w w . ja v a2s. c om*/ try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); filePathOriginal = buildFilePathOriginal(foldername, "jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, buildCaptureUri(filePathOriginal)); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new ChooserException(e); } return filePathOriginal; }
From source file:com.example.android.shuttershock.MainActivity.java
private void takePic() { Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraIntent, 2); }
From source file:com.android.camera.v2.uimanager.ThumbnailManager.java
/** * Create a thumbnail manager controller. * @param appcontroller controller used to get service for storage. * @param activity the current activity. * @param parent view group.//w w w. j a va 2s.com * @param secureCamera whether the current camera is secure camera or not. */ public ThumbnailManager(AppController appcontroller, Activity activity, ViewGroup parent, boolean secureCamera) { super(activity, parent); mIsSecureCamera = secureCamera; setFilterEnable(false); mStorageService = appcontroller.getAppControllerAdapter().getServices().getStorageService(); mActivity = activity; mContentResolver = activity.getContentResolver(); mMaiHandler = new Handler(activity.getMainLooper()); HandlerThread t = new HandlerThread("thumbnail-creation-thread"); t.start(); mHandler = new ThumbnailCreatorHandler(t.getLooper()); mThumbnailAnimation = new ThumbnailAnimation(); LocalBroadcastManager manager = LocalBroadcastManager.getInstance(mActivity); manager.registerReceiver(mUpdatePictureReceiver, mUpdatePictureFilter); mActivity.registerReceiver(mIpoShutdownReceiver, mIpoShutdownFilter); mIntent = activity.getIntent(); String action = null; if (mIntent != null) { action = mIntent.getAction(); } if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action) || MediaStore.ACTION_VIDEO_CAPTURE.equals(action) || CameraUtil.ACTION_STEREO3D.equals(action)) { mShownByIntent = false; } }
From source file:cn.xcom.helper.activity.AuthorizedActivity.java
private void showPickDialog() { new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT) .setNegativeButton("", new DialogInterface.OnClickListener() { @Override/*from w w w . j a va2 s . c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent albumIntent = new Intent(); albumIntent.setType("image/*"); albumIntent.setAction(Intent.ACTION_PICK); startActivityForResult(albumIntent, PHOTO_REQUEST_ALBUM); } }).setPositiveButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); int permissionCheck = ContextCompat.checkSelfPermission(mContext, Manifest.permission.CAMERA); if (permissionCheck == PackageManager.PERMISSION_GRANTED) { Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { File path = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM); File file = new File(path, "51helper.jpg"); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); } startActivityForResult(cameraIntent, PHOTO_REQUEST_CAMERA); } else if (permissionCheck == PackageManager.PERMISSION_DENIED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) mContext, Manifest.permission.CAMERA)) { // Show an expanation to the user *asynchronously* -- don't block // this thread waiting for the user's response! After the user // sees the explanation, try again to request the permission. } else { // No explanation needed, we can request the permission. ActivityCompat.requestPermissions((Activity) mContext, new String[] { Manifest.permission.CAMERA }, MY_PERMISSIONS_REQUEST_READ_CONTACTS); // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an // app-defined int constant. The callback method gets the // result of the request. } } } }).show(); }
From source file:general.me.edu.dgtmovil.dgtmovil.formregisestudiante.FormEstudDosFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_form_estud_dos, container, false); deco = new LectorCedulasDeco(); obli_cuatro = (TextView) view.findViewById(R.id.p9_obligatorio); addDesSiete = (ImageView) view.findViewById(R.id.btn_addComCole); addDesSiete.setOnClickListener(this); addDesNueve = (ImageView) view.findViewById(R.id.btn_addComEmail); addDesNueve.setOnClickListener(this); addDesDiez = (ImageView) view.findViewById(R.id.btn_addComTrama); addDesDiez.setOnClickListener(this); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); p10 = (EditText) view.findViewById(R.id.p10); p11 = (EditText) view.findViewById(R.id.p11); p9 = (Spinner) view.findViewById(R.id.p9); lp9 = (TextView) view.findViewById(R.id.lp9); lp10 = (TextView) view.findViewById(R.id.lp10); lp11 = (TextView) view.findViewById(R.id.lp11); bt_guardar = (Button) view.findViewById(R.id.buttonGuardar); leerCedula = (ImageView) view.findViewById(R.id.leer_cedula); leerCedula.setOnClickListener(this); Bundle bundle = getActivity().getIntent().getExtras(); //Construimos el mensaje a mostrar //CODIGO PARA LA FOTO btnFoto = (ImageView) view.findViewById(R.id.btn_foto); btnFoto.setOnClickListener(new View.OnClickListener() { @Override/* w w w . java 2 s . c o m*/ public void onClick(View v) { Intent goCamara = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(goCamara, CONS); } }); idUsuario = bundle.getString("idUsuario"); idPerfil = bundle.getString("perfil"); idEntidad = bundle.getString("idEntidad"); idFormulario = bundle.getString("idFormulario"); gestionDatos = new GestionDatos(getActivity()); crearBaseDatos(); gestionDatos.sentencias = sentencias; firma = (ImageView) view.findViewById(R.id.img_firma); firma.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Bundle b = new Bundle(); b.putString("img", "imgSola"); Intent intent = new Intent(getActivity(), CaptureSignature.class); intent.putExtras(b); startActivityForResult(intent, SIGNATURE_ACTIVITY); } }); preguntas = gestionDatos.listarPreguntas(idFormulario); opciones = gestionDatos.listarOpciones(idEntidad); if (preguntas != null && preguntas.length > 0) { Pregunta pre = getPregunta("9"); lp9.setText(pre.DESCRIPCION); pre = getPregunta("10"); lp10.setText(pre.DESCRIPCION); pre = getPregunta("11"); lp11.setText(pre.DESCRIPCION); fijarOpciones("9", p9); ; } bt_guardar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { guardarFormulario(); } }); return view; }