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.mercandalli.android.apps.files.file.FileAddDialog.java
@SuppressWarnings("PMD.AvoidUsingHardCodedIP") public FileAddDialog(@NonNull final Activity activity, final int id_file_parent, @Nullable final IListener listener, @Nullable final IListener dismissListener) { super(activity, R.style.DialogFullscreen); mActivity = activity;//from w w w .j a v a2 s .c om mDismissListener = dismissListener; mFileParentId = id_file_parent; mListener = listener; setContentView(R.layout.dialog_add_file); setCancelable(true); final View rootView = findViewById(R.id.dialog_add_file_root); rootView.startAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.dialog_add_file_open)); rootView.setOnClickListener(this); findViewById(R.id.dialog_add_file_upload_file).setOnClickListener(this); findViewById(R.id.dialog_add_file_add_directory).setOnClickListener(this); findViewById(R.id.dialog_add_file_text_doc).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogUtils.prompt(mActivity, mActivity.getString(R.string.dialog_file_create_txt), mActivity.getString(R.string.dialog_file_name_interrogation), mActivity.getString(R.string.dialog_file_create), new DialogUtils.OnDialogUtilsStringListener() { @Override public void onDialogUtilsStringCalledBack(String text) { //TODO create a online txt with content Toast.makeText(getContext(), getContext().getString(R.string.not_implemented), Toast.LENGTH_SHORT).show(); } }, mActivity.getString(android.R.string.cancel), null); FileAddDialog.this.dismiss(); } }); findViewById(R.id.dialog_add_file_scan).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { 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 ApplicationActivity.sPhotoFile = createImageFile(); // Continue only if the File was successfully created if (ApplicationActivity.sPhotoFile != null) { if (listener != null) { ApplicationActivity.sPhotoFileListener = listener; } takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(ApplicationActivity.sPhotoFile.getFile())); mActivity.startActivityForResult(takePictureIntent, ApplicationActivity.REQUEST_TAKE_PHOTO); } } FileAddDialog.this.dismiss(); } }); findViewById(R.id.dialog_add_file_add_timer).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar currentTime = Calendar.getInstance(); DialogDatePicker dialogDate = new DialogDatePicker(mActivity, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, final int year, final int monthOfYear, final int dayOfMonth) { Calendar currentTime = Calendar.getInstance(); DialogTimePicker dialogTime = new DialogTimePicker(mActivity, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Log.d("TIme Picker", hourOfDay + ":" + minute); final SimpleDateFormat dateFormatGmt = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.US); dateFormatGmt.setTimeZone(TimeZone.getTimeZone("UTC")); final SimpleDateFormat dateFormatLocal = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss", Locale.US); String nowAsISO = dateFormatGmt.format(new Date()); final JSONObject json = new JSONObject(); try { json.put("type", "timer"); json.put("date_creation", nowAsISO); json.put("timer_date", "" + dateFormatGmt.format(dateFormatLocal.parse(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth + " " + hourOfDay + ":" + minute + ":00"))); final SimpleDateFormat dateFormatGmtTZ = new SimpleDateFormat( "yyyy-MM-dd'T'HH-mm'Z'", Locale.US); dateFormatGmtTZ.setTimeZone(TimeZone.getTimeZone("UTC")); nowAsISO = dateFormatGmtTZ.format(new Date()); final List<StringPair> parameters = new ArrayList<>(); parameters.add(new StringPair("content", json.toString())); parameters.add(new StringPair("name", "TIMER_" + nowAsISO)); parameters.add( new StringPair("id_file_parent", "" + id_file_parent)); new TaskPost(mActivity, Constants.URL_DOMAIN + Config.ROUTE_FILE, new IPostExecuteListener() { @Override public void onPostExecute(JSONObject json, String body) { if (listener != null) { listener.execute(); } } }, parameters).execute(); } catch (JSONException | ParseException e) { Log.e(getClass().getName(), "Failed to convert Json", e); } } }, currentTime.get(Calendar.HOUR_OF_DAY), currentTime.get(Calendar.MINUTE), true); dialogTime.show(); } }, currentTime.get(Calendar.YEAR), currentTime.get(Calendar.MONTH), currentTime.get(Calendar.DAY_OF_MONTH)); dialogDate.show(); FileAddDialog.this.dismiss(); } }); findViewById(R.id.dialog_add_file_article).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogCreateArticle dialogCreateArticle = new DialogCreateArticle(mActivity, listener); dialogCreateArticle.show(); FileAddDialog.this.dismiss(); } }); FileAddDialog.this.show(); }
From source file:net.coding.program.project.init.create.ProjectCreateFragment.java
private void camera() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = CameraPhotoUtil.getOutputMediaFileUri(); intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); startActivityForResult(intent, RESULT_REQUEST_PHOTO); }
From source file:com.karthiknr.visionid.MainActivity.java
protected void startCameraActivity() { File file = new File(_path); Uri outputFileUri = Uri.fromFile(file); final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, 0);/* w w w . ja v a 2 s . c om*/ }
From source file:com.liferay.mobile.screens.viewsets.defaultviews.ddl.form.fields.DDLDocumentFieldView.java
protected AlertDialog createOriginDialog() { Activity activity = LiferayScreensContext.getActivityFromContext(getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(activity); LayoutInflater factory = LayoutInflater.from(activity); final View customDialogView = factory.inflate(R.layout.ddlfield_document_chose_option_default, null); View takeVideoButton = customDialogView.findViewById(R.id.liferay_dialog_take_video_form); RxPermissions rxPermissions = new RxPermissions(activity); RxView.clicks(takeVideoButton)/*from ww w. j a v a2 s.co m*/ .compose(rxPermissions.ensure(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)) .subscribe(launchCamera(MediaStore.ACTION_VIDEO_CAPTURE)); View takePhotoButton = customDialogView.findViewById(R.id.liferay_dialog_take_photo_form); RxView.clicks(takePhotoButton) .compose(rxPermissions.ensure(Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE)) .subscribe(launchCamera(MediaStore.ACTION_IMAGE_CAPTURE)); final View selectFileButton = customDialogView.findViewById(R.id.liferay_dialog_select_file_form); RxView.clicks(selectFileButton).compose(rxPermissions.ensure(Manifest.permission.WRITE_EXTERNAL_STORAGE)) .subscribe(chooseFile(selectFileButton)); builder.setView(customDialogView); return builder.create(); }
From source file:com.glasshack.checkmymath.CheckMyMath.java
public void takePicture() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, TAKE_PICTURE_REQUEST); }
From source file:ca.taglab.PictureFrame.ScreenSlidePageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout containing a title and body text. final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_screen_slide_page, container, false);//w w w . j a va2 s . c om Bitmap picture = BitmapFactory.decodeFile(mImgPath); rootView.setBackground(new BitmapDrawable(getResources(), picture)); mConfirmation = (ImageView) rootView.findViewById(R.id.confirm); ((TextView) rootView.findViewById(R.id.name)).setText(mName); rootView.findViewById(R.id.control).getBackground().setAlpha(200); optionsOpen = false; mMsgHistory = rootView.findViewById(R.id.msg); mMsgHistory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); hideOptions(); } }); mPhoto = rootView.findViewById(R.id.photo); mPhoto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".jpg"; ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, filename); mCapturedImageURI = getActivity().getContentResolver() .insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI); startActivityForResult(intent, CAPTURE_PICTURE); hideOptions(); } catch (Exception e) { Log.e(TAG, "Camera intent failed"); } } }); mVideo = rootView.findViewById(R.id.video); mVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { String filename = String.valueOf(System.currentTimeMillis()) + ".3gp"; ContentValues values = new ContentValues(); values.put(MediaStore.Video.Media.TITLE, filename); mCapturedVideoURI = getActivity().getContentResolver() .insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedVideoURI); startActivityForResult(intent, CAPTURE_VIDEO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Video intent failed"); } } }); mAudio = rootView.findViewById(R.id.audio); mAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = new Intent(getActivity(), AudioRecorderActivity.class); startActivityForResult(intent, CAPTURE_AUDIO); hideOptions(); } catch (Exception e) { Log.e(TAG, "Audio intent failed"); } } }); mWave = rootView.findViewById(R.id.wave); mWave.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { new SendEmailAsyncTask(getActivity(), mEmail, "PictureFrame: I'm thinking of you", "Wave sent via PictureFrame", null).execute(); //Toast.makeText(getActivity(), "Wave sent to: " + mEmail, Toast.LENGTH_SHORT).show(); hideOptions(); messageSent(v); } catch (Exception e) { Log.e("SendEmailAsyncTask", e.getMessage(), e); //Toast.makeText(getActivity(), "Wave to " + mEmail + " failed", Toast.LENGTH_SHORT).show(); } } }); mCancel = rootView.findViewById(R.id.close); mPhoto.getBackground().setAlpha(200); mVideo.getBackground().setAlpha(200); mAudio.getBackground().setAlpha(200); mWave.getBackground().setAlpha(200); mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); mLongAnimationDuration = getResources().getInteger(android.R.integer.config_longAnimTime); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!optionsOpen) showOptions(); } }); mCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (optionsOpen) hideOptions(); } }); Cursor unread = getActivity().getContentResolver().query(UserContentProvider.MESSAGE_CONTENT_URI, MessageTable.PROJECTION, MessageTable.COL_TO_ID + "=? AND " + MessageTable.COL_FROM_ID + "=? AND " + MessageTable.COL_READ + "=?", new String[] { Long.toString(mOwnerId), Long.toString(mId), Long.toString(0) }, null); if (unread != null && unread.moveToFirst()) { rootView.findViewById(R.id.notification).setVisibility(View.VISIBLE); rootView.findViewById(R.id.notification).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), MessagesActivity.class); intent.putExtra("user_name", mName); intent.putExtra("user_id", mId); intent.putExtra("owner_id", mOwnerId); startActivity(intent); v.setVisibility(View.INVISIBLE); } }); } if (unread != null) { unread.close(); } return rootView; }
From source file:com.hch.beautyenjoy.tools.IntentUtils.java
/** * Open camera//from ww w.j av a 2 s .c om */ public static void openCamera(Context context) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); if (componentName != null) { context.startActivity(intent); } }
From source file:com.example.shinelon.ocrcamera.MainActivity.java
@Override public void onClick(View view) { switch (view.getId()) { ////from w w w . j a v a 2 s . c om case R.id.gallery_bt: Intent intent2 = new Intent(Intent.ACTION_GET_CONTENT); intent2.setType("image/*"); startActivityForResult(intent2, SELECT); break; case R.id.txt_bt: OCRRecognitionTask task = new OCRRecognitionTask(); task.execute(); break; case R.id.camera_bt: //? Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //putExtra()???? intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); startActivityForResult(intent, REQUEST_CAMERA); break; case R.id.crop_bt: //?? crop(getUri()); break; default: break; } }
From source file:com.github.dfa.diaspora_android.activity.ShareActivity.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from w w w. j av a 2 s. c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main__activity); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); if (toolbar != null) { toolbar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (Helpers.isOnline(ShareActivity.this)) { Intent intent = new Intent(ShareActivity.this, MainActivity.class); startActivityForResult(intent, 100); overridePendingTransition(0, 0); finish(); } else { Snackbar.make(swipeView, R.string.no_internet, Snackbar.LENGTH_LONG).show(); } } }); } setTitle(R.string.new_post); progressBar = (ProgressBar) findViewById(R.id.progressBar); swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe); swipeView.setEnabled(false); podDomain = ((App) getApplication()).getSettings().getPodDomain(); webView = (WebView) findViewById(R.id.webView); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); WebSettings wSettings = webView.getSettings(); wSettings.setJavaScriptEnabled(true); wSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT >= 21) wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); /* * WebViewClient */ webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, url); if (!url.contains(podDomain)) { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); return true; } return false; } public void onPageFinished(WebView view, String url) { Log.i(TAG, "Finished loading URL: " + url); } }); /* * WebChromeClient */ webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView wv, int progress) { progressBar.setProgress(progress); if (progress > 0 && progress <= 60) { Helpers.getNotificationCount(wv); } if (progress > 60) { Helpers.applyDiasporaMobileSiteChanges(wv); } if (progress == 100) { progressBar.setVisibility(View.GONE); } else { progressBar.setVisibility(View.VISIBLE); } } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (mFilePathCallback != null) mFilePathCallback.onReceiveValue(null); mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Snackbar.make(getWindow().findViewById(R.id.main__layout), "Unable to get image", Snackbar.LENGTH_LONG).show(); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); if (savedInstanceState == null) { if (Helpers.isOnline(ShareActivity.this)) { webView.loadUrl("https://" + podDomain + "/status_messages/new"); } else { Snackbar.make(getWindow().findViewById(R.id.main__layout), R.string.no_internet, Snackbar.LENGTH_LONG).show(); } } Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { if (intent.hasExtra(Intent.EXTRA_SUBJECT)) { handleSendSubject(intent); } else { handleSendText(intent); } } else if (type.startsWith("image/")) { // TODO Handle single image being sent -> see manifest handleSendImage(intent); } //} else { // Handle other intents, such as being started from the home screen } }
From source file:com.cpjd.roblu.ui.images.ImageGalleryActivity.java
/** * The user clicked the plus button and wants to add a new image * @param v the floating action button that was clicked *//*from w w w . j a va2s .com*/ @Override public void onClick(View v) { if (!editable) return; if (EasyPermissions.hasPermissions(this, android.Manifest.permission.CAMERA)) { tempPictureFile = new IO(getApplicationContext()).getTempPictureFile(); Uri fileUri = FileProvider.getUriForFile(getApplicationContext(), "com.cpjd.roblu", tempPictureFile); Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); camera.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); startActivityForResult(camera, Constants.GENERAL); } else { Utils.showSnackbar(layout, getApplicationContext(), "Camera permission is disabled. Please enable it.", true, 0); } }