本文整理汇总了Java中android.os.Environment.DIRECTORY_PICTURES属性的典型用法代码示例。如果您正苦于以下问题:Java Environment.DIRECTORY_PICTURES属性的具体用法?Java Environment.DIRECTORY_PICTURES怎么用?Java Environment.DIRECTORY_PICTURES使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.os.Environment
的用法示例。
在下文中一共展示了Environment.DIRECTORY_PICTURES属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveAllSelectedStatus
private void saveAllSelectedStatus(ArrayList<String> statuses){
String fileType = Environment.DIRECTORY_PICTURES;
for(String status : statuses){
if(status.endsWith(".jpg")){
fileType = "Pictures";
}else if(status.endsWith(".gif")){
fileType ="Gifs";
}else if(status.endsWith(".mp4")){
fileType="Videos";
}
String [] splitStatus = status.split("/");
String destinationFilename = android.os.Environment.getExternalStorageDirectory().getAbsolutePath()
+"/WhatsAppSaver"+File.separatorChar+splitStatus[splitStatus.length-1];
try {
copyFile(new File(status),new File(destinationFilename));
Intent intent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE");
intent.setData(Uri.fromFile(new File(destinationFilename)));
sendBroadcast(intent);
} catch (IOException e) {
e.printStackTrace();
}
}
}
示例2: getOutputMediaFile
private File getOutputMediaFile(int type) {
// Get environment directory type id from requested media type.
String environmentDirectoryType;
if (type == MEDIA_TYPE_IMAGE) {
environmentDirectoryType = Environment.DIRECTORY_PICTURES;
} else if (type == MEDIA_TYPE_VIDEO) {
environmentDirectoryType = Environment.DIRECTORY_MOVIES;
} else {
Log.e(TAG, "Unsupported media type:" + type);
return null;
}
return getOutputFile(
type,
Environment.getExternalStoragePublicDirectory(environmentDirectoryType)
);
}
示例3: createImageFile
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = (isVideo ? "MPEG_" : "JPEG_") + timeStamp + "_";
String dirType = isVideo ? Environment.DIRECTORY_MOVIES : Environment.DIRECTORY_PICTURES;
File storageDir = isPublic ? getExternalStoragePublicDirectory(dirType) :
getExternalFilesDir(dirType);
if( !storageDir.exists() ) {
storageDir.mkdirs();
}
File image = File.createTempFile(
imageFileName,
isVideo ? ".mp4" : ".jpg",
storageDir
);
return image;
}
示例4: getOutputMediaFile
private File getOutputMediaFile(String fileName) {
// Get environment directory type id from requested media type.
String environmentDirectoryType;
environmentDirectoryType = Environment.DIRECTORY_PICTURES;
return getOutputFile(
fileName + ".jpeg",
Environment.getExternalStoragePublicDirectory(environmentDirectoryType)
);
}
示例5: openFilePickerDialog
/**
* Open a file picker dialog to ease select a new image from external storage.
*/
public void openFilePickerDialog() {
DialogProperties properties = new DialogProperties();
properties.selection_mode = DialogConfigs.SINGLE_MODE;
properties.selection_type = DialogConfigs.FILE_SELECT;
// initial directory should be pictures directory
properties.offset = new File("/mnt/sdcard" + File.separator + Environment.DIRECTORY_PICTURES);
// show accepted image format only
properties.extensions = new String[]{"jpg","jpeg","png","gif","bmp","webp"};
FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
dialog.setTitle(R.string.dialog_edit_doc_cover_image_select_title);
dialog.setPositiveBtnName(getString(R.string.dialog_edit_doc_cover_image_select_ok));
dialog.setNegativeBtnName(getString(android.R.string.cancel));
dialog.setDialogSelectionListener(new DialogSelectionListener() {
@Override
public void onSelectedFilePaths(String[] files) {
if (files.length > 0) {
mImagePath = files[0];
updateImage();
}
}
});
dialog.show();
// There is a problem with library dialog theme, it does not support a light
// primary color because header text color is always white.
// With this hack (we had to study library layout) it ensures that header background
// is ok.
dialog.findViewById(R.id.header).setBackgroundColor(
ContextCompat.getColor(getActivity(), R.color.colorAccent));
}
示例6: getDirectoryPath
private String getDirectoryPath() {
if (directoryPath == null || directoryPath.isEmpty()) {
return Environment.DIRECTORY_PICTURES;
} else {
return directoryPath;
}
}
示例7: getImageDir
public static File getImageDir() throws NoExternalStorageException {
return new File(getSignalStorageDir(), Environment.DIRECTORY_PICTURES);
}