本文整理汇总了Java中android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI属性的典型用法代码示例。如果您正苦于以下问题:Java Media.EXTERNAL_CONTENT_URI属性的具体用法?Java Media.EXTERNAL_CONTENT_URI怎么用?Java Media.EXTERNAL_CONTENT_URI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.MediaStore.Images.Media
的用法示例。
在下文中一共展示了Media.EXTERNAL_CONTENT_URI属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showFileChooser
private void showFileChooser() {
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK,
Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
photoPickerIntent.putExtra("crop", "true");
photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri());
photoPickerIntent.putExtra("outputFormat", CompressFormat.JPEG.toString());
startActivityForResult(photoPickerIntent, PICK_IMAGE_REQUEST);
}
示例2: onCreateLoader
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
if (id == 0) {
return new CursorLoader(MultiImageSelectorFragment.this.getActivity(), Media.EXTERNAL_CONTENT_URI, this.IMAGE_PROJECTION, null, null, this.IMAGE_PROJECTION[2] + " DESC");
} else if (id != 1) {
return null;
} else {
return new CursorLoader(MultiImageSelectorFragment.this.getActivity(), Media.EXTERNAL_CONTENT_URI, this.IMAGE_PROJECTION, this.IMAGE_PROJECTION[0] + " like '%" + args.getString("path") + "%'", null, this.IMAGE_PROJECTION[2] + " DESC");
}
}
示例3: getPath
@SuppressLint({"NewApi"})
public String getPath(Context context, Uri uri) {
boolean isKitKat;
if (VERSION.SDK_INT >= 19) {
isKitKat = true;
} else {
isKitKat = false;
}
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
String[] split;
if (isExternalStorageDocument(uri)) {
split = DocumentsContract.getDocumentId(uri).split(NetworkUtils.DELIMITER_COLON);
if ("primary".equalsIgnoreCase(split[0])) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
return null;
} else if (isDownloadsDocument(uri)) {
return getDataColumn(context, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(DocumentsContract.getDocumentId(uri)).longValue()), null, null);
} else if (!isMediaDocument(uri)) {
return null;
} else {
String type = DocumentsContract.getDocumentId(uri).split(NetworkUtils.DELIMITER_COLON)[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = Audio.Media.EXTERNAL_CONTENT_URI;
}
String selection = "_id=?";
return getDataColumn(context, contentUri, "_id=?", new String[]{split[1]});
}
} else if (WidgetRequestParam.REQ_PARAM_COMMENT_CONTENT.equalsIgnoreCase(uri.getScheme())) {
if (isGooglePhotosUri(uri)) {
return uri.getLastPathSegment();
}
return getDataColumn(context, uri, null, null);
} else if (IDataSource.SCHEME_FILE_TAG.equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
} else {
return null;
}
}
示例4: getPicPathFromUri
@TargetApi(19)
private String getPicPathFromUri(Uri uri) {
boolean isKitKat;
if (VERSION.SDK_INT >= 19) {
isKitKat = true;
} else {
isKitKat = false;
}
if (isKitKat && DocumentsContract.isDocumentUri(this, uri)) {
String[] split;
if (isExternalStorageDocument(uri)) {
split = DocumentsContract.getDocumentId(uri).split(com.letv.pp.utils.NetworkUtils.DELIMITER_COLON);
if ("primary".equalsIgnoreCase(split[0])) {
return Environment.getExternalStorageDirectory() + "/" + split[1];
}
return null;
} else if (isDownloadsDocument(uri)) {
return getDataColumn(this, ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(DocumentsContract.getDocumentId(uri)).longValue()), null, null);
} else if (!isMediaDocument(uri)) {
return null;
} else {
String type = DocumentsContract.getDocumentId(uri).split(com.letv.pp.utils.NetworkUtils.DELIMITER_COLON)[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = Audio.Media.EXTERNAL_CONTENT_URI;
}
String selection = "_id=?";
return getDataColumn(this, contentUri, "_id=?", new String[]{split[1]});
}
} else if (WidgetRequestParam.REQ_PARAM_COMMENT_CONTENT.equalsIgnoreCase(uri.getScheme())) {
if (isGooglePhotosUri(uri)) {
return uri.getLastPathSegment();
}
return getDataColumn(this, uri, null, null);
} else if (IDataSource.SCHEME_FILE_TAG.equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
} else {
return null;
}
}
示例5: getContentUriTrigger
static ContentUriTrigger getContentUriTrigger() {
ObservedUri contactUri =
new ObservedUri(ContactsContract.AUTHORITY_URI, Flags.FLAG_NOTIFY_FOR_DESCENDANTS);
ObservedUri imageUri = new ObservedUri(Media.EXTERNAL_CONTENT_URI, 0);
return Trigger.contentUriTrigger(Arrays.asList(contactUri, imageUri));
}
示例6: pickImage
public static void pickImage(Activity activity, int action) {
Uri targetUri = Media.EXTERNAL_CONTENT_URI;
String folderPath = DsaTabApplication.getDirectory(DsaTabApplication.DIR_PORTRAITS).getAbsolutePath();
String folderBucketId = Integer.toString(folderPath.toLowerCase(Locale.GERMAN).hashCode());
targetUri = targetUri.buildUpon().appendQueryParameter(ImageColumns.BUCKET_ID, folderBucketId).build();
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setData(targetUri);
activity.startActivityForResult(Intent.createChooser(photoPickerIntent, "Bild auswählen"), action);
}