获取Android上照片画廊名单 [英] Get list of photo galleries on Android

查看:119
本文介绍了获取Android上照片画廊名单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找: 现有相册名称的列表(希望他们的首要缩略图以及) 画廊的内容(然后我可以加载的缩略图,并根据需要全尺寸)

I'm looking for: A list of the existing photo gallery names (hopefully their top thumbnail as well) The contents of the gallery (I can then load thumbnails and full size as needed)

我将如何去获得的画廊名单(不知道这是正确的术语在用于Android的可见光图像在画廊的应用程序...的分组)和它们的内容是什么?我需要访问库在它的不使用现有的画廊显示结构(我创建一个全新的,而不是过层到照片请求等。)

How would I go about getting a list of the "Galleries" (don't know if that's the proper term in android for the groupings of images visible in the Gallery app...) and their contents? I need access to the gallery in it's structure without using the existing gallery display (I'm creating a totally new one, not an over layer to the photo requestor etc.)

我想MediaStore.Images是哪里我需要,但我没有看到任何东西,这将使我的分组...

I assume MediaStore.Images is where I need to be but I don't see anything that will give me the groupings...

推荐答案

分组由 MediaStore.Images.Media.BUCKET_DISPLAY_NAME 定义。下面是示例code列出的图像和记录他们的斗名,date_taken:

Groupings are defined by MediaStore.Images.Media.BUCKET_DISPLAY_NAME. Here is the sample code to list the images and log their bucket name and date_taken:

    // which image properties are we querying
    String[] projection = new String[]{
            MediaStore.Images.Media._ID,
            MediaStore.Images.Media.BUCKET_DISPLAY_NAME,
            MediaStore.Images.Media.DATE_TAKEN
    };

    // content:// style URI for the "primary" external storage volume
    Uri images = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

    // Make the query.
    Cursor cur = managedQuery(images,
            projection, // Which columns to return
            null,       // Which rows to return (all rows)
            null,       // Selection arguments (none)
            null        // Ordering
            );

    Log.i("ListingImages"," query count="+cur.getCount());

    if (cur.moveToFirst()) {
        String bucket;
        String date;
        int bucketColumn = cur.getColumnIndex(
            MediaStore.Images.Media.BUCKET_DISPLAY_NAME);

        int dateColumn = cur.getColumnIndex(
            MediaStore.Images.Media.DATE_TAKEN);

        do {
            // Get the field values
            bucket = cur.getString(bucketColumn);
            date = cur.getString(dateColumn);

            // Do something with the values.
            Log.i("ListingImages", " bucket=" + bucket 
                   + "  date_taken=" + date);
        } while (cur.moveToNext());

    }

这篇关于获取Android上照片画廊名单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆