您的位置:首页 > 其它

打开本地相册,获取照片

2016-04-19 16:25 357 查看
权限

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<span style="font-size:14px;">Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,  "image/*");
startActivityForResult(intent, OPEN_PHOTO_REQUESTCODE);  //返回值是本地图片的URI

根据URI获取图片
ContentResolver cr = context.getContentResolver();
InputStream inputStream = null;
inputStream = cr.openInputStream(uri);
Bitmap result = BitmapFactory.decodeStream(inputStream, null, options);
inputStream.close();
</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: