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