当前位置: 首页>>代码示例>>Java>>正文


Java Media.query方法代码示例

本文整理汇总了Java中android.provider.MediaStore.Images.Media.query方法的典型用法代码示例。如果您正苦于以下问题:Java Media.query方法的具体用法?Java Media.query怎么用?Java Media.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.provider.MediaStore.Images.Media的用法示例。


在下文中一共展示了Media.query方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRealPathByUri

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
public static String getRealPathByUri(Context context, Uri uri) {
    if ("file".equals(uri.getScheme())) {
        return uri.getPath();
    }
    try {
        Cursor cursor = Media.query(context.getContentResolver(), uri, new String[]{"_data"});
        String realPath = null;
        if (cursor == null) {
            return null;
        }
        int columnIndex = cursor.getColumnIndexOrThrow("_data");
        if (cursor.getCount() > 0 && cursor.moveToFirst()) {
            realPath = cursor.getString(columnIndex);
        }
        cursor.close();
        return realPath;
    } catch (Exception e) {
        return uri.getPath();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:MQUtils.java

示例2: getBuckets

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
static List<Image> getBuckets(Context context) {
    final Cursor cursor = Media.query(context.getContentResolver(), URI, PROJECTION,
            "1 = 1) GROUP BY (" + Media.BUCKET_ID,  // WTF
            Media.DATE_ADDED + " DESC");

    final List<Image> images = new ArrayList<>();
    final File root = Environment.getExternalStorageDirectory();

    if (cursor.moveToFirst()) {
        do {
            final Image image = Image.fromCursor(cursor);
            if (image.getParentFile().equals(root)) {
                continue;
            }
            images.add(image);
        } while (cursor.moveToNext());
    }

    cursor.close();

    return images;
}
 
开发者ID:oxoooo,项目名称:nomedia,代码行数:23,代码来源:MediaStoreUtils.java

示例3: getImages

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
static List<Image> getImages(Context context, String bucketId, int limit) {
    final Cursor cursor = Media.query(context.getContentResolver(), URI, PROJECTION,
            Media.BUCKET_ID + " = ?", new String[]{bucketId},
            Media.DATE_ADDED + " DESC");

    final List<Image> images = new ArrayList<>();
    int count = 0;

    if (cursor.moveToFirst()) {
        do {
            images.add(Image.fromCursor(cursor));
            count++;
        } while (count < limit && cursor.moveToNext());
    }

    cursor.close();

    return images;
}
 
开发者ID:oxoooo,项目名称:nomedia,代码行数:20,代码来源:MediaStoreUtils.java

示例4: getBucketIds

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
public HashMap<String, String> getBucketIds() {
    Uri uri = mBaseUri.buildUpon()
            .appendQueryParameter("distinct", "true").build();
    Cursor cursor = Media.query(
            mContentResolver, uri,
            new String[] {
                Media.BUCKET_DISPLAY_NAME,
                Media.BUCKET_ID},
            whereClause(), whereClauseArgs(), null);
    try {
        HashMap<String, String> hash = new HashMap<String, String>();
        while (cursor.moveToNext()) {
            hash.put(cursor.getString(1), cursor.getString(0));
        }
        return hash;
    } finally {
        cursor.close();
    }
}
 
开发者ID:petalyaa,项目名称:Launchpet2,代码行数:20,代码来源:ImageList.java

示例5: getBucketIds

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
public HashMap<String, String> getBucketIds() {
    Uri uri = mBaseUri.buildUpon().appendQueryParameter("distinct", "true").build();
    Cursor cursor = Media.query(mContentResolver, uri, new String[]{Media.BUCKET_DISPLAY_NAME, Media.BUCKET_ID}, whereClause(), whereClauseArgs(), null);
    try {
        HashMap<String, String> hash = new HashMap<String, String>();
        while (cursor.moveToNext()) {
            hash.put(cursor.getString(1), cursor.getString(0));
        }
        return hash;
    } finally {
        cursor.close();
    }
}
 
开发者ID:goodev,项目名称:droidddle,代码行数:14,代码来源:ImageList.java

示例6: createCursor

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
@Override
protected Cursor createCursor() {
    Cursor c = Media.query(
            mContentResolver, mBaseUri, IMAGE_PROJECTION,
            whereClause(), whereClauseArgs(), sortOrder());
    return c;
}
 
开发者ID:petalyaa,项目名称:Launchpet2,代码行数:8,代码来源:ImageList.java

示例7: createCursor

import android.provider.MediaStore.Images.Media; //导入方法依赖的package包/类
@Override
protected Cursor createCursor() {
    Cursor c = Media.query(mContentResolver, mBaseUri, IMAGE_PROJECTION, whereClause(), whereClauseArgs(), sortOrder());
    return c;
}
 
开发者ID:goodev,项目名称:droidddle,代码行数:6,代码来源:ImageList.java


注:本文中的android.provider.MediaStore.Images.Media.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。