以下代码从手机/ SD卡上的本地图片中获取图像缩略图:
public Task<List<Album>> GetAllAlbumsAndPhotos(object activity)
{
Activity activ = activity as Activity;
List<Album> albums = new List<Album>();
// which image properties are we querying
String[] projection = new String[]
{
MediaStore.Images.Media.InterfaceConsts.BucketId,
MediaStore.Images.Media.InterfaceConsts.BucketDisplayName,
MediaStore.Images.Media.InterfaceConsts.DateTaken,
MediaStore.Images.Media.InterfaceConsts.DateAdded,
MediaStore.Images.Media.InterfaceConsts.Data
};
// Get the base URI for the People table in the Contacts content provider.
AndroidNet.Uri images = MediaStore.Images.Media.ExternalContentUri;
// Make the query.
var cursor = activ.ContentResolver.Query(images,
projection, // Which columns to return
"", // Which rows to return (all rows)
null, // Selection arguments (none)
"" // Ordering
);
if (cursor.MoveToFirst())
{
int bucketColumn = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.BucketDisplayName);
int takenColumn = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DateTaken);
int addedColumn = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.DateAdded);
int dataColumn = cursor.GetColumnIndex(MediaStore.Images.Media.InterfaceConsts.Data);
do
{
.
.
.
} while (cursor.MoveToNext());
}
return Task.FromResult(albums);
}
如何添加视频缩略图?可以使用相同的代码完成,还是必须独立于此代码块完成?