本文整理汇总了Java中android.provider.DocumentsContract.isDocumentUri方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentsContract.isDocumentUri方法的具体用法?Java DocumentsContract.isDocumentUri怎么用?Java DocumentsContract.isDocumentUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.provider.DocumentsContract
的用法示例。
在下文中一共展示了DocumentsContract.isDocumentUri方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleImageOnKitkat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitkat(Intent data){
String imagePath=null;
Uri uri=data.getData();
if (DocumentsContract.isDocumentUri(this,uri)){
//如果是document類型的Uri。則通過document id 處理
String docId=DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=docId.split(":")[1];//解析出文字格式的id
String selection=MediaStore.Images.Media._ID+"="+id;
imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
} else if("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri= ContentUris.withAppendedId(Uri.parse("content://downloads/public" +
"_downloads"),Long.valueOf(docId));
}
}else if ("content".equalsIgnoreCase(uri.getScheme())){
//如果是content類型的Uri,則是用普通方式處理
imagePath=getImagePath(uri,null);
}else if ("file".equalsIgnoreCase(uri.getScheme())){
//如果是file類型的Uri,直接獲取圖片路徑即可
imagePath=uri.getPath();
}
displayImage(imagePath);//根據圖片路徑顯示圖片
}
示例2: handleImage
import android.provider.DocumentsContract; //导入方法依赖的package包/类
private void handleImage(Uri uri){
String imagePath = null;
if(DocumentsContract.isDocumentUri(getActivity(), uri)){
String docId = DocumentsContract.getDocumentId(uri);
if("com.android.providers.media.documents".equals(uri.getAuthority())){
String id = docId.split(":")[1];
String selection = MediaStore.Images.Media._ID+"="+id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
}
else if("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
imagePath = getImagePath(contentUri, null);
}
}
else if("content".equalsIgnoreCase(uri.getScheme())){
imagePath = getImagePath(uri, null);
}
else if("file".equalsIgnoreCase(uri.getScheme())){
imagePath = uri.getPath();
}
filePath = imagePath;
Log.i(TAG, "handleImage: Album filepath"+filePath);
getQiniuUpToken();
}
示例3: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
/**
* 执行打开相册逻辑
*/
@TargetApi(19)
private String handleImageOnKitKat(Intent data) {
String imagePath = null;
Uri uri = data.getData();
if (DocumentsContract.isDocumentUri(this, uri)) {
String docId = DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
String id = docId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=" + id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
Long.valueOf(docId));
imagePath = getImagePath(contentUri, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
imagePath = getImagePath(uri, null);
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
imagePath = uri.getPath();
}
return imagePath;
}
示例4: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
public void handleImageOnKitKat(Intent data) {
String imagePath=null;
Uri uri=data.getData();
if (DocumentsContract.isDocumentUri(this,uri)){
//如果是document类型的Uri,则通过document id处理
String docId=DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=docId.split(":")[1];//解析数字可是的id
String selection=MediaStore.Images.Media._ID+"="+id;
imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
}else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri= ContentUris.withAppendedId(Uri.parse("content://downloads/punlic_downloads"),Long.valueOf(docId));
imagePath=getImagePath(contentUri,null);
}
}else if ("content".equalsIgnoreCase(uri.getScheme())){
//如果是content类型的Uri,则使用普通方法
imagePath=getImagePath(uri,null);
}else if ("file".equalsIgnoreCase(uri.getScheme())){
imagePath=uri.getPath();
}
displayImage(imagePath);//根据图片路径显示图片
}
示例5: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data){
String imagePath=null;
Uri uri=data.getData();
if (DocumentsContract.isDocumentUri(getActivity(),uri)){
//如果是 document 类型的 Uri,则通过document id处理
String docId=DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=docId.split(":")[1]; //解析出数字格式的id
String selection=MediaStore.Images.Media._ID+"="+id;
imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
}else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri= ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),
Long.valueOf(docId));
imagePath=getImagePath(contentUri,null);
}
}else if ("content".equalsIgnoreCase(uri.getScheme())){
//如果是content类型的Uri 则使用普通方式处理
imagePath=getImagePath(uri,null);
}else if ("file".equalsIgnoreCase(uri.getScheme())){
//如果是file类型的Uri,直接获取图片路径即可
imagePath=uri.getPath();
}
displayImage(imagePath); //根据图片路径显示图片
}
示例6: getPicturePathFromUriAboveApi19
import android.provider.DocumentsContract; //导入方法依赖的package包/类
private static String getPicturePathFromUriAboveApi19(Context context, Uri uri) {
String filePath = null;
if (DocumentsContract.isDocumentUri(context, uri)) {
// 如果是document类型的 uri, 则通过document id来进行处理
String documentId = DocumentsContract.getDocumentId(uri);
if (isMediaDocument(uri)) { // MediaProvider
// 使用':'分割
String id = documentId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=?";
String[] selectionArgs = {id};
filePath = getDataColumn(context, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection, selectionArgs);
} else if (isDownloadsDocument(uri)) { // DownloadsProvider
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId));
filePath = getDataColumn(context, contentUri, null, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
// 如果是 content 类型的 Uri
filePath = getDataColumn(context, uri, null, null);
} else if ("file".equals(uri.getScheme())) {
// 如果是 file 类型的 Uri,直接获取图片对应的路径
filePath = uri.getPath();
}
return filePath;
}
示例7: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data){
String imagePath = null;
Uri uri = data.getData();
if(DocumentsContract.isDocumentUri(this,uri)){
String docId = DocumentsContract.getDocumentId(uri);
if("com.android.provider.media,documents".equals(uri.getAuthority())){
String id = docId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=" + id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
}else if("com.android.provider.downloads.documents".equals(uri.getAuthority())){
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),Long.valueOf(docId));
imagePath = getImagePath(contentUri,null);
}
}else if("content".equalsIgnoreCase(uri.getScheme())){
imagePath = getImagePath(uri,null);
}else if("file".equalsIgnoreCase(uri.getScheme())){
imagePath = uri.getPath();
}
displayImage(imagePath);//根据图片路径显示图片
}
示例8: handleImage
import android.provider.DocumentsContract; //导入方法依赖的package包/类
private String handleImage(Intent data) {
imagePath = null;
Uri uri = data.getData();
if (DocumentsContract.isDocumentUri(this, uri)) {
String docId = DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
String id = docId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=" + id;
imagePath = getPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
Uri contentUri = ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"),
Long.valueOf(docId));
imagePath = getPath(contentUri, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
imagePath = getPath(uri, null);
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
imagePath = uri.getPath();
}
return imagePath;
}
示例9: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data) {
String imagePath = null;
Uri uri = data.getData();
if (DocumentsContract.isDocumentUri(mView.getActivity(), uri)) {
// 如果是documentlent类型的URI,则通过docment id处理
String docId = DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
String id = docId.split(":")[1];
String selection = MediaStore.Images.Media._ID + "=" + id;
imagePath = getImagePatch(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
imagePath = getImagePatch(contentUri, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
// 如果是content类型的uri的话,则使用普通方式处理
imagePath = getImagePatch(uri, null);
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
// 若果是file类型的uri,则直接获取图片路径
imagePath = uri.getPath();
}
copyFileInOtherThread(imagePath);
}
示例10: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
/**
* @param data
* @return 图片路径
*/
public static String handleImageOnKitKat(Intent data) {
String imagePath = "";
Log.i(TAG, "handleImageOnKitKat: ");
Uri uri = data.getData();
if (DocumentsContract.isDocumentUri(MyApplication.getContext(), uri)) {
//如果是document类型的uri,则通过document id处理
String docId = DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
String id = docId.split(":")[1];//解析出数字格式的ID
String selection = MediaStore.Images.Media._ID + "=" + id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection);
} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(docId));
imagePath = getImagePath(contentUri, null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
//如果是content类型的uri,则使用普通的方式处理
imagePath = getImagePath(uri, null);
} else if ("file".equalsIgnoreCase(uri.getScheme())) {
//如果是file类型的uri,直接获取图片路径即可
imagePath = uri.getPath();
}
return imagePath;
}
示例11: handleImageBeforeKitkat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
public void handleImageBeforeKitkat(Intent data) {
String imagePath=null;
Uri uri=data.getData();
if(DocumentsContract.isDocumentUri(mActivity, uri)){
String docid=DocumentsContract.getDocumentId(uri);
if("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=docid.split(":")[1];
String selection= MediaStore.Images.Media._ID+"="+id;
imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
}else if("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri= ContentUris.withAppendedId(
Uri.parse("content://downloads/public_downloads"), Long.valueOf(docid));
imagePath=getImagePath(contentUri,null);
}
}else if("content".equalsIgnoreCase(uri.getScheme())){
imagePath=getImagePath(uri,null);
}
//剪裁图片
cropImage(imagePath);
}
示例12: getPath
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
public static String getPath(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
try {
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
return handleKitKatVersion(context, uri);
} // MediaStore (and general)
else if ("content".equalsIgnoreCase(uri.getScheme())) {
return getDataColumn(context, uri, null, null);
}
// File
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return uri.getPath();
}
} catch (Exception e) {
DebugLog.e(e.getMessage());
}
return null;
}
示例13: getDocumentId
import android.provider.DocumentsContract; //导入方法依赖的package包/类
public String getDocumentId()
{
try
{
if (DocumentsContract.isDocumentUri(mContext, mUri))
{
return DocumentsContract.getDocumentId(mUri);
} else
{
return DocumentsContract.getTreeDocumentId(mUri);
}
}
catch (IllegalArgumentException e)
{
// This is not a document uri, for now I'll try to handle this gracefully.
// While it may be convenient for a user to be able to use this object for all uri,
// it may be difficult to manage all aspects gracefully.
return null;
}
}
示例14: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data) {
String imagePath = null;
Uri uri = data.getData();
if (DocumentsContract.isDocumentUri(this,uri)) {
// 如果是document类型的Uri,则通过document id处理
String docId = DocumentsContract.getDocumentId(uri);
if ("com.android.providers.media.documents".equals(uri.getAuthority())) {
String id = docId.split(":")[1]; // 解析出数字格式的ID
String selection = MediaStore.Images.Media._ID+"="+id;
imagePath = getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
} else if ("com.android.providers.downloads.documents".equals(uri.getAuthority())) {
Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"),Long.valueOf(docId));
imagePath = getImagePath(contentUri,null);
}
} else if ("content".equalsIgnoreCase(uri.getScheme())) {
// 如果不是document类型的Uri,则使用普通方式处理
imagePath = getImagePath(uri,null);
}
// 根据图片路径显示图片
displayImage(imagePath);
}
示例15: handleImageOnKitKat
import android.provider.DocumentsContract; //导入方法依赖的package包/类
@TargetApi(19)
private void handleImageOnKitKat(Intent data){
String imagePath=null;
Uri uri=data.getData();
if(DocumentsContract.isDocumentUri(this,uri)){
String docId=DocumentsContract.getDocumentId(uri);
if("com.android.providers.media.documents".equals(uri.getAuthority())){
String id=docId.split(":")[1];
String selection=MediaStore.Images.Media._ID+"="+id;
imagePath=getImagePath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,selection);
}else if("com.android.providers.downloads.documents".equals(uri.getAuthority())){
Uri contentUri=ContentUris.withAppendedId(Uri.parse("cintent://downloads/public_downloads"),Long.valueOf(docId));
imagePath=getImagePath(contentUri,null);
}
}else if("content".equalsIgnoreCase(uri.getScheme())){
imagePath=getImagePath(uri,null);
}
displayImage(imagePath);
}