操作系统相册和获取相册路径

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

posted @ 2014-07-24 16:09  Self_improve  阅读(420)  评论(0编辑  收藏  举报