本文整理匯總了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);
}