首页 > 代码库 > 操作系统相册和获取相册路径
操作系统相册和获取相册路径
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType(IMAGE_TYPE);
startActivityForResult(intent, 2);
ContentResolver resolver = getContentResolver();
try {
Uri uri = data.getData();
bitmap = MediaStore.Images.Media.getBitmap(resolver, uri);
bm = ThumbnailUtils.extractThumbnail(bitmap, 300, 150);
handler.sendEmptyMessage(1);
//获取图片路径
String[] porj = {MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(uri, porj, null, null, null);
int index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
String path = cursor.getString(index);
LogUtils.v("相册路径:"+path);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
参考:http://blog.csdn.net/hugh114/article/details/5765332