List of usage examples for android.provider MediaStore EXTRA_OUTPUT
String EXTRA_OUTPUT
To view the source code for android.provider MediaStore EXTRA_OUTPUT.
Click Source Link
From source file:com.feytuo.chat.activity.ChatActivity.java
/** * ?//from www. j av a 2s . c o m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), App.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:mobisocial.bento.ebento.ui.EditFragment.java
private void goCamera() { File tmpFile = JpgFileHelper.getTmpFile(); Intent intent = new Intent(); intent.setAction("android.media.action.IMAGE_CAPTURE"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpFile)); startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); }
From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java
public static void takePicture(final Activity context) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); try {/*from w w w . java 2 s.com*/ Uri mImageCaptureUri = null; String state = Environment.getExternalStorageState(); if (Environment.MEDIA_MOUNTED.equals(state)) { mImageCaptureUri = Uri.fromFile(AppData.getSingletonObject().getmFileTemp()); } else { mImageCaptureUri = InternalStorageContentProvider.CONTENT_URI; } intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri); intent.putExtra("return-data", true); context.startActivityForResult(intent, ConstantUtil.REQUEST_CODE_TAKE_PICTURE); } catch (ActivityNotFoundException e) { Log.d(ConstantUtil.BLANK_TEXT, "cannot take picture", e); } }
From source file:com.aidigame.hisun.imengstar.huanxin.ChatActivity.java
/** * ?/* w w w . ja va 2 s .c o m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), com.aidigame.hisun.imengstar.PetApplication.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.stikyhive.stikyhive.ChattingActivity.java
public void showPhoto() { AlertDialog.Builder builder = new AlertDialog.Builder(this); String[] strArray = { "Take photo", "Choose from Gallery" }; builder.setTitle("Select Photo").setItems(strArray, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // The 'which' argument contains the index position // of the selected item switch (which) { case 0: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); /*****/*from w w w .j a v a2 s . c om*/ * Define the file-name to save photo taken by * Camera activity *******/ String fileName = "Camera_Example.jpg"; // Create parameters for Intent with filename ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); values.put(MediaStore.Images.Media.DESCRIPTION, "Image capture by camera"); /****** * imageUri is the current activity attribute, * define and save it for later usage *****/ imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // start the image capture Intent startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); Log.i("Camera ", " Testing..."); break; case 1: // start GalleryUtil Activity to choose photo from // Gallery Intent gallery_Intent = new Intent("com.arctech.GALLERYUTIL"); gallery_Intent.putExtra("type", "image"); startActivityForResult(gallery_Intent, GALLERY_ACTIVITY_CODE); break; default: break; } } }); builder.create(); builder.show(); }
From source file:com.android.mms.ui.MessageUtils.java
public static void recordVideo(Activity activity, int requestCode, long sizeLimit) { // The video recorder can sometimes return a file that's larger than the max we // say we can handle. Try to handle that overshoot by specifying an 85% limit. /// M: media recoder can handle this issue,so mark it. // sizeLimit *= .85F; int durationLimit = getVideoCaptureDurationLimit(); if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) { log("recordVideo: durationLimit: " + durationLimit + " sizeLimit: " + sizeLimit); }// w w w. j a va 2 s. co m Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); intent.putExtra("android.intent.extra.sizeLimit", sizeLimit); intent.putExtra("android.intent.extra.durationLimit", durationLimit); /// M: Code analyze 009, For fix bug ALPS00241707, You can not add // capture video to Messaging after you preview it in Gallery. @{ intent.putExtra(MediaStore.EXTRA_OUTPUT, TempFileProvider.SCRAP_VIDEO_URI); /// M: fix bug ALPS01043585 intent.putExtra("CanShare", false); activity.startActivityForResult(intent, requestCode); }
From source file:com.liangxun.university.huanxin.chat.activity.ChatActivity.java
/** * ?//from w w w . j a v a2 s .c om */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), getMyApp().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.example.zf_android.trade.ApplyDetailActivity.java
private void setupItem(LinearLayout item, int itemType, final String key, final String value) { switch (itemType) { case ITEM_EDIT: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); EditText etValue = (EditText) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key);// ww w .java 2 s .c om if (!TextUtils.isEmpty(value)) etValue.setText(value); break; } case ITEM_CHOOSE: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key); if (!TextUtils.isEmpty(value)) tvValue.setText(value); break; } case ITEM_UPLOAD: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); final TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key); tvValue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { uploadingTextView = tvValue; AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this); final String[] items = getResources().getStringArray(R.array.apply_detail_upload); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, REQUEST_UPLOAD_IMAGE); break; } case 1: { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File outDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!outDir.exists()) { outDir.mkdirs(); } File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); photoPath = outFile.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } else { CommonUtil.toastShort(ApplyDetailActivity.this, getString(R.string.toast_no_sdcard)); } break; } } } }); builder.show(); } }); break; } case ITEM_VIEW: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); ImageButton ibView = (ImageButton) item.findViewById(R.id.apply_detail_view); if (!TextUtils.isEmpty(key)) tvKey.setText(key); ibView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class); i.putExtra("url", value); i.putExtra("justviewer", true); startActivity(i); } }); } } }
From source file:com.example.Bama.chat.chatuidemo.activity.ChatActivity.java
/** * ?//w w w. j a v a 2 s . co m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { String st = getResources().getString(R.string.sd_card_does_not_exist); Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), HCApplication.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.kll.collect.android.activities.FormEntryActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); Log.i("Request Code", Integer.toString(requestCode)); Log.i("Result Code", Integer.toString(resultCode)); FormController formController = Collect.getInstance().getFormController(); if (formController == null) { // we must be in the midst of a reload of the FormController. // try to save this callback data to the FormLoaderTask if (mFormLoaderTask != null && mFormLoaderTask.getStatus() != AsyncTask.Status.FINISHED) { mFormLoaderTask.setActivityResult(requestCode, resultCode, intent); } else {/*from ww w. ja v a 2 s . c o m*/ Log.e(t, "Got an activityResult without any pending form loader"); } return; } compressImage = mSharedPreferences.getBoolean(PreferencesActivity.KEY_ENABLE_IMAGE_COMPRESSION, false); if (resultCode == RESULT_CANCELED) { // request was canceled... if (requestCode != HIERARCHY_ACTIVITY) { ((ODKView) mCurrentView).cancelWaitingForBinaryData(); } return; } Log.i("Request Code ", Integer.toString(requestCode)); switch (requestCode) { case BARCODE_CAPTURE: String sb = intent.getStringExtra("SCAN_RESULT"); ((ODKView) mCurrentView).setBinaryData(sb); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case EX_STRING_CAPTURE: case EX_INT_CAPTURE: case EX_DECIMAL_CAPTURE: String key = "value"; boolean exists = intent.getExtras().containsKey(key); if (exists) { Object externalValue = intent.getExtras().get(key); ((ODKView) mCurrentView).setBinaryData(externalValue); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); } break; case EX_GROUP_CAPTURE: try { Bundle extras = intent.getExtras(); ((ODKView) mCurrentView).setDataForFields(extras); } catch (JavaRosaException e) { Log.e(t, e.getMessage(), e); createErrorDialog(e.getCause().getMessage(), DO_NOT_EXIT); } break; case DRAW_IMAGE: case ANNOTATE_IMAGE: case SIGNATURE_CAPTURE: case IMAGE_CAPTURE: /* * We saved the image to the tempfile_path, but we really want it to * be in: /sdcard/odk/instances/[current instnace]/something.jpg so * we move it there before inserting it into the content provider. * Once the android image capture bug gets fixed, (read, we move on * from Android 1.6) we want to handle images the audio and video */ // The intent is empty, but we know we saved the image to the temp // file Log.i("Request Code ", Integer.toString(requestCode)); File fi = new File(Collect.TMPFILE_PATH); String mInstanceFolder = formController.getInstancePath().getParent(); String s = mInstanceFolder + File.separator + System.currentTimeMillis() + ".jpg"; File nf = new File(s); if (!fi.renameTo(nf)) { Log.e(t, "Failed to rename " + fi.getAbsolutePath()); } else { Log.i(t, "renamed " + fi.getAbsolutePath() + " to " + nf.getAbsolutePath()); } Log.i("Filename of image", String.valueOf(nf)); if (compressImage) compreesImage(s); ((ODKView) mCurrentView).setBinaryData(nf); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case ALIGNED_IMAGE: /* * We saved the image to the tempfile_path; the app returns the full * path to the saved file in the EXTRA_OUTPUT extra. Take that file * and move it into the instance folder. */ String path = intent.getStringExtra(android.provider.MediaStore.EXTRA_OUTPUT); fi = new File(path); mInstanceFolder = formController.getInstancePath().getParent(); s = mInstanceFolder + File.separator + System.currentTimeMillis() + ".jpg"; nf = new File(s); if (!fi.renameTo(nf)) { Log.e(t, "Failed to rename " + fi.getAbsolutePath()); } else { Log.i(t, "renamed " + fi.getAbsolutePath() + " to " + nf.getAbsolutePath()); } if (compressImage) compreesImage(s); ((ODKView) mCurrentView).setBinaryData(nf); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case IMAGE_CHOOSER: /* * We have a saved image somewhere, but we really want it to be in: * /sdcard/odk/instances/[current instnace]/something.jpg so we move * it there before inserting it into the content provider. Once the * android image capture bug gets fixed, (read, we move on from * Android 1.6) we want to handle images the audio and video */ // get gp of chosen file Uri selectedImage = intent.getData(); String sourceImagePath = MediaUtils.getPathFromUri(this, selectedImage, Images.Media.DATA); // Copy file to sdcard String mInstanceFolder1 = formController.getInstancePath().getParent(); String destImagePath = mInstanceFolder1 + File.separator + System.currentTimeMillis() + ".jpg"; File source = new File(sourceImagePath); File newImage = new File(destImagePath); FileUtils.copyFile(source, newImage); if (compressImage) compreesImage(destImagePath); ((ODKView) mCurrentView).setBinaryData(newImage); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case AUDIO_CAPTURE: case VIDEO_CAPTURE: case AUDIO_CHOOSER: case VIDEO_CHOOSER: // For audio/video capture/chooser, we get the URI from the content // provider // then the widget copies the file and makes a new entry in the // content provider. Uri media = intent.getData(); ((ODKView) mCurrentView).setBinaryData(media); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case LOCATION_CAPTURE: Log.i("Request Code ", Integer.toString(requestCode)); String sl = intent.getStringExtra(LOCATION_RESULT); ((ODKView) mCurrentView).setBinaryData(sl); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case GEOSHAPE_CAPTURE: //String ls = intent.getStringExtra(GEOSHAPE_RESULTS); String gshr = intent.getStringExtra(GEOSHAPE_RESULTS); ((ODKView) mCurrentView).setBinaryData(gshr); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case GEOTRACE_CAPTURE: String traceExtra = intent.getStringExtra(GEOTRACE_RESULTS); ((ODKView) mCurrentView).setBinaryData(traceExtra); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); break; case BEARING_CAPTURE: String bearing = intent.getStringExtra(BEARING_RESULT); ((ODKView) mCurrentView).setBinaryData(bearing); saveAnswersForCurrentScreen(DO_NOT_EVALUATE_CONSTRAINTS); case HIERARCHY_ACTIVITY: // We may have jumped to a new index in hierarchy activity, so // refresh break; } refreshCurrentView(); }