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:it.rignanese.leo.slimfacebook.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setup the sharedPreferences savedPreferences = PreferenceManager.getDefaultSharedPreferences(this); //setup the theme //int savedThemeId = Integer.parseInt(savedPreferences.getString("pref_key_theme8", "2131361965"));//get the last saved theme id //setTheme(savedThemeId);//this refresh the theme if necessary // TODO fix the change of status bar setContentView(R.layout.activity_main);//load the layout // setup the refresh layout swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container); swipeRefreshLayout.setColorSchemeResources(R.color.officialBlueFacebook, R.color.darkBlueSlimFacebookTheme);// set the colors swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override// w ww. j a v a 2s . c o m public void onRefresh() { refreshPage();//reload the page swipeRefresh = true; } }); // setup the webView webViewFacebook = (WebView) findViewById(R.id.webView); setUpWebViewDefaults(webViewFacebook);//set the settings goHome();//load homepage //WebViewClient that is the client callback. webViewFacebook.setWebViewClient(new WebViewClient() {//advanced set up // when there isn't a connetion public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { String summary = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><h1 " + "style='text-align:center; padding-top:15%;'>" + getString(R.string.titleNoConnection) + "</h1> <h3 style='text-align:center; padding-top:1%; font-style: italic;'>" + getString(R.string.descriptionNoConnection) + "</h3> <h5 style='text-align:center; padding-top:80%; opacity: 0.3;'>" + getString(R.string.awards) + "</h5></body></html>"; webViewFacebook.loadData(summary, "text/html; charset=utf-8", "utf-8");//load a custom html page noConnectionError = true; swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing } // when I click in a external link public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url == null || url.contains("facebook.com")) { //url is ok return false; } else { if (url.contains("https://scontent")) { //TODO add the possibility to download and share directly Toast.makeText(getApplicationContext(), getString(R.string.downloadOrShareWithBrowser), Toast.LENGTH_LONG).show(); //TODO get bitmap from url Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } //if the link doesn't contain 'facebook.com', open it using the browser startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } } //START management of loading @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { //TODO when I push on messages, open messanger // if(url!=null){ // if (url.contains("soft=messages") || url.contains("facebook.com/messages")) { // Toast.makeText(getApplicationContext(),"Open Messanger", // Toast.LENGTH_SHORT).show(); // startActivity(new Intent(getPackageManager().getLaunchIntentForPackage("com.facebook.orca")));//messanger // } // } // show you progress image if (!swipeRefresh) { final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(R.layout.circular_progress_bar); } swipeRefresh = false; super.onPageStarted(view, url, favicon); } @Override public void onPageFinished(WebView view, String url) { // hide your progress image final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh); refreshItem.setActionView(null); super.onPageFinished(view, url); swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing } //END management of loading }); //WebChromeClient for handling all chrome functions. webViewFacebook.setWebChromeClient(new WebChromeClient() { //to upload files //thanks to gauntface //https://github.com/GoogleChrome/chromium-webview-samples public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getBaseContext().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 } // 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; } }); }
From source file:com.example.deii.Fragments.UpdateProfileFragment.java
protected void startCamera() { // TODO Auto-generated method stub profileImageCaptured = new File(Environment.getExternalStorageDirectory() + "/" + "temp.png"); if (profileImageCaptured.exists()) profileImageCaptured.delete();// www .jav a 2 s . c om outputFileUri = Uri.fromFile(profileImageCaptured); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); intent.putExtra("return-data", true); startActivityForResult(intent, CAMERA_REQUEST); }
From source file:com.cw.litenote.note_add.Note_addCameraImage.java
private void takeImageWithName() { Intent takeImageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takeImageIntent.resolveActivity(getPackageManager()) != null) { // Create temporary image File where the photo will save in File tempFile = null;/*from ww w . j ava 2s. com*/ try { tempFile = createTempImageFile(); } catch (IOException ex) { // Error occurred while creating the File } // Continue only if the File was successfully created if (tempFile != null) { imageUri = Uri.fromFile(tempFile); // so far, file size is 0 takeImageIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // appoint Uri for captured image imageUriInDB = imageUri.toString(); startActivityForResult(takeImageIntent, TAKE_IMAGE_ACT); } } }
From source file:com.android.gallery3d.gadget.WidgetConfigure.java
private void setChoosenPhoto(final Intent data) { AsyncTask.execute(new Runnable() { @Override/*from w w w. j a va 2 s. co m*/ public void run() { Resources res = getResources(); float width = res.getDimension(R.dimen.appwidget_width); float height = res.getDimension(R.dimen.appwidget_height); // We try to crop a larger image (by scale factor), but there is still // a bound on the binder limit. float scale = Math.min(WIDGET_SCALE_FACTOR, MAX_WIDGET_SIDE / Math.max(width, height)); int widgetWidth = Math.round(width * scale); int widgetHeight = Math.round(height * scale); File cropSrc = new File(getCacheDir(), "crop_source.png"); File cropDst = new File(getCacheDir(), "crop_dest.png"); mPickedItem = data.getData(); if (!copyUriToFile(mPickedItem, cropSrc)) { setResult(Activity.RESULT_CANCELED); finish(); return; } mCropSrc = FileProvider.getUriForFile(WidgetConfigure.this, "com.android.gallery3d.fileprovider", new File(cropSrc.getAbsolutePath())); mCropDst = FileProvider.getUriForFile(WidgetConfigure.this, "com.android.gallery3d.fileprovider", new File(cropDst.getAbsolutePath())); Intent request = new Intent(CropActivity.CROP_ACTION).putExtra(CropExtras.KEY_OUTPUT_X, widgetWidth) .putExtra(CropExtras.KEY_OUTPUT_Y, widgetHeight) .putExtra(CropExtras.KEY_ASPECT_X, widgetWidth) .putExtra(CropExtras.KEY_ASPECT_Y, widgetHeight) .putExtra(CropExtras.KEY_SCALE_UP_IF_NEEDED, true).putExtra(CropExtras.KEY_SCALE, true) .putExtra(CropExtras.KEY_RETURN_DATA, false).setDataAndType(mCropSrc, "image/*") .addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); request.putExtra(MediaStore.EXTRA_OUTPUT, mCropDst); request.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, mCropDst)); startActivityForResult(request, REQUEST_CROP_IMAGE); } }); }
From source file:com.android.settings.users.EditUserPhotoController.java
private void appendOutputExtra(Intent intent, Uri pictureUri) { intent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, pictureUri)); }
From source file:com.ultramegasoft.flavordex2.fragment.AbsPhotosFragment.java
/** * Launch an image capturing Intent./* ww w . j a v a 2s. c o m*/ */ final void takePhoto() { final Context context = getContext(); final Fragment parent = getParentFragment(); if (context == null || parent == null) { return; } final Intent intent = PhotoUtils.getTakePhotoIntent(context); if (intent != null && intent.resolveActivity(getContext().getPackageManager()) != null) { mCapturedPhoto = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT); parent.startActivityForResult(intent, REQUEST_CAPTURE_IMAGE); return; } Toast.makeText(context, R.string.error_camera, Toast.LENGTH_LONG).show(); }
From source file:info.guardianproject.iocipher.camera.VideoCameraActivity.java
@Override public void onPictureTaken(final byte[] data, Camera camera) { File fileSecurePicture;//from w w w .j a va2s .co m try { overlayView.setBackgroundResource(R.color.flash); long mTime = System.currentTimeMillis(); fileSecurePicture = new File(mFileBasePath, "secure_image_" + mTime + ".jpg"); BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileSecurePicture)); out.write(data); out.flush(); out.close(); mResultList.add(fileSecurePicture.getAbsolutePath()); Intent intent = new Intent("new-media"); // You can also include some extra data. intent.putExtra("media", fileSecurePicture.getAbsolutePath()); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); Intent intentResult = new Intent().putExtra(MediaStore.EXTRA_OUTPUT, mResultList.toArray(new String[mResultList.size()])); setResult(Activity.RESULT_OK, intentResult); view.postDelayed(new Runnable() { @Override public void run() { overlayView.setBackgroundColor(Color.TRANSPARENT); resumePreview(); } }, 100); } catch (Exception e) { e.printStackTrace(); setResult(Activity.RESULT_CANCELED); } }
From source file:com.googlecode.android_scripting.facade.CameraFacade.java
@Rpc(description = "Starts the image capture application to take a picture and saves it to the specified path.") public void cameraInteractiveCapturePicture(@RpcParameter(name = "targetPath") final String targetPath) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(targetPath); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file)); AndroidFacade facade = mManager.getReceiver(AndroidFacade.class); facade.startActivityForResult(intent); }
From source file:com.ceino.chaperonandroid.activities.LicenseActivity.java
private void selectImage() { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override/*from w w w . ja v a 2s . c o m*/ public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File f = new File(Environment.getExternalStorageDirectory(), "temp.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, 1); } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 2); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:com.renard.ocr.documents.creation.NewDocumentActivity.java
protected void startCamera() { mAnalytics.startCamera();//w w w .j av a2 s. c om try { cameraPicUri = null; dateCameraIntentStarted = new Date(); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File image; try { if (!storageDir.exists()) { storageDir.mkdirs(); } image = new File(storageDir, imageFileName + ".jpg"); if (image.exists()) { image.createNewFile(); } cameraPicUri = Uri.fromFile(image); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraPicUri); startActivityForResult(intent, REQUEST_CODE_MAKE_PHOTO); } catch (IOException e) { showFileError(PixLoadStatus.IO_ERROR); } } catch (ActivityNotFoundException e) { showFileError(PixLoadStatus.CAMERA_APP_NOT_FOUND); } }