打开本地相册,获取照片

权限

<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>


你可能感兴趣的:(打开本地相册,获取照片)