List of usage examples for android.os Environment DIRECTORY_PICTURES
String DIRECTORY_PICTURES
To view the source code for android.os Environment DIRECTORY_PICTURES.
Click Source Link
From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK && requestCode == UCrop.REQUEST_CROP) { File cropFile = new File(UCrop.getOutput(data).getPath()); int index = 0; for (int id : postImageViewIds) { ImageView mImageView = (ImageView) rootView.findViewById(id); if (mImageView.getTag() == null) { rootView.findViewById(postImageViewPlusIds[index]).setVisibility(View.VISIBLE); rootView.findViewById(postImageViewRemoveIds[index]).setVisibility(View.VISIBLE); mImageView.setImageBitmap(BitmapFactory.decodeFile(cropFile.getPath())); mImageView.setScaleType(ImageView.ScaleType.FIT_XY); mImageView.setPadding(10, 10, 10, 10); mImageView.setTag(cropFile.getPath()); mImageViewTitle.setImageDrawable(((ImageView) rootView.findViewById(id)).getDrawable()); mImageViewTitle.setTag(id); break; }//from www . ja va2s . c o m index++; } } else if (resultCode == Activity.RESULT_OK && requestCode == PICK_PHOTO_FOR_AVATAR) { UCrop.of(data.getData(), Uri.fromFile( new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"))) .withMaxResultSize(1920, 1920).start(getContext(), this); } else if (resultCode == Activity.RESULT_OK && requestCode == TAKE_PHOTO_FOR_AVATAR) { UCrop.of(Uri.fromFile(takeFile), Uri.fromFile( new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), System.currentTimeMillis() + ".jpg"))) .withMaxResultSize(1920, 1920).start(getContext(), this); } else if (resultCode == UCrop.RESULT_ERROR) { final Throwable cropError = UCrop.getError(data); Log.d("mox", "croperror" + cropError.toString()); } else if (resultCode == Activity.RESULT_OK && requestCode == SEARCH_ADDRESS) { AddressModel mAddressModel = (AddressModel) data.getSerializableExtra("data"); setAddressModel(mAddressModel); } else if (resultCode == Activity.RESULT_OK && requestCode == PICK_VIDEO_FOR_AVATAR) { String path = getPath(data.getData()); showVideoAlertDialog(path); } else if (resultCode == Activity.RESULT_OK && requestCode == TAKE_VIDEO_FOR_AVATAR) { String path = takeFile.getPath(); showVideoAlertDialog(path); } }
From source file:com.ddoskify.CameraOverlayActivity.java
private static File getOutputMediaFile() { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "ddoskify"); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.e("Ddoski", "failed to create directory " + mediaStorageDir.toString()); return null; }/*from w w w.j a va2 s . c o m*/ } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); File mediaFile; mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); return mediaFile; }
From source file:com.remobile.camera.CameraLauncher.java
private String getPicutresPath() { String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "IMG_" + timeStamp + ".jpg"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); String galleryPath = storageDir.getAbsolutePath() + "/" + imageFileName; return galleryPath; }
From source file:com.example.zf_android.activity.MerchantEdit.java
private void show3Dialog(int type, final String uri) { AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this); final String[] items = getResources().getStringArray(R.array.apply_detail_view); MerchantEdit.this.type = type; builder.setItems(items, new DialogInterface.OnClickListener() { @Override/*w ww. j a va2s . c o m*/ public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { AlertDialog.Builder build = new AlertDialog.Builder(MerchantEdit.this); LayoutInflater factory = LayoutInflater.from(MerchantEdit.this); final View textEntryView = factory.inflate(R.layout.show_view, null); build.setView(textEntryView); final ImageView view = (ImageView) textEntryView.findViewById(R.id.imag); // ImageCacheUtil.IMAGE_CACHE.get(uri, view); ImageLoader.getInstance().displayImage(uri, view, options); build.create().show(); break; } case 1: { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_UPLOAD_IMAGE); break; } case 2: { 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(MerchantEdit.this, getString(R.string.toast_no_sdcard)); } break; } } } }); builder.show(); }
From source file:com.example.innf.newchangtu.Map.view.activity.MainActivity.java
private File getTrackPhotoFile(Track track) { if (track != null) { File externalFilesDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); if (null == externalFilesDir) { Log.d(TAG, "+------+\n| |\n+------+"); return null; }/*from w w w .j a v a 2 s. c om*/ Log.d(TAG, track.getPhotoFilename(track)); return new File(externalFilesDir, track.getPhotoFilename(track)); } return null; }
From source file:com.rsmsa.accapp.MainActivity.java
/** * returning image / video// w w w .j a v a 2 s .com */ private static File getOutputMediaFile(int type) { // External sdcard location File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), IMAGE_DIRECTORY_NAME); // Create the storage directory if it does not exist if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d(IMAGE_DIRECTORY_NAME, "Oops! Failed create " + IMAGE_DIRECTORY_NAME + " directory"); return null; } } // Create a media file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date()); File mediaFile; if (type == MEDIA_TYPE_IMAGE) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } else if (type == MEDIA_TYPE_VIDEO) { mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4"); } else { return null; } return mediaFile; }
From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java
private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); return File.createTempFile(imageFileName, /* prefix */ ".jpg", /* suffix */ storageDir /* directory */ );//from w w w. java 2s .c o m }
From source file:org.totschnig.myexpenses.util.Utils.java
public static File getPictureDir(boolean secure) { File result;//from w w w. j a va 2s . c o m if (secure) { result = new File(MyApplication.getInstance().getFilesDir(), "images"); } else { result = MyApplication.getInstance().getExternalFilesDir(Environment.DIRECTORY_PICTURES); } if (result == null) return null; result.mkdir(); return result.exists() ? result : null; }
From source file:com.stfalcon.contentmanager.ContentManager.java
/** * Create image file in directory of pictures * * @param content//from ww w.jav a 2 s . c o m * @return */ public static File createFile(Content content) { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String type = content.equals(Content.IMAGE) ? ".jpg" : ".mp4"; String imageFileName = "IMAGE_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File image = null; try { image = File.createTempFile(imageFileName, /* prefix */ type, /* suffix */ storageDir /* directory */ ); } catch (IOException e) { e.printStackTrace(); } return image; }
From source file:org.artoolkit.ar.samples.ARMovie.ARMovieActivity.java
private static File getOutputMediaFile() { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "ARCloud"); if (!mediaStorageDir.exists()) { if (!mediaStorageDir.mkdirs()) { Log.d("ARCloud", "failed to create directory 2"); return null; }/* ww w. j a v a 2s . co m*/ } String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); return new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); }