문제
SD 카드에서 이미지를 찾거나 카메라에서 찍은 이미지를 찾고 있습니다.
이상적인 솔루션은 이미지에 대한 파일 경로 또는 URI 모음을 얻는 것입니다. 나는 당신이 중간을 통해 이것을 할 수 있다고 생각합니다.
감사
해결책
더 많은 중간 예제를 살펴본 후 나는 이것을 생각해 냈고 그것은 일을 끝냅니다.
protected ArrayList<Uri> GetImageList(boolean getThumbs)
{
ArrayList<Uri> images = new ArrayList<Uri>();
String columnType;
Uri contentType;
String[] columnNames;
if (getThumbs)
{
columnType = MediaStore.Images.Thumbnails._ID;
contentType = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI;
}
else
{
columnType = MediaStore.Images.Media._ID;
contentType = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
}
columnNames = new String[]{columnType};
Cursor cursor = managedQuery(contentType, columnNames, null, null, null);
int columnIndex = cursor.getColumnIndexOrThrow(columnType);
for(int i = 0; i < cursor.getCount(); i++)
{
cursor.moveToPosition(i);
int id = cursor.getInt(columnIndex);
images.add(Uri.withAppendedPath(contentType, "" + id));
}
return images;
}
SDCard의 모든 이미지의 모든 이미지 또는 URI의 URI를 반환합니다.
제휴하지 않습니다 StackOverflow