我知道如何从
android中的相册中获取照片
Intent gallery = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(gallery,PHOTO_REQUEST_CODE);
但是我如何专门选择缩略图?
BOUNTY的原因:
我已经在Get thumbnail Uri/path of the image stored in sd card + android尝试了两种解决方案.他们不适合我.我不知道如何从数据中获取selectedImageUri,类型为long
onActivityResult(int requestCode,int resultCode,Intent data)
解决方法
String fn = ...; // file name ContentResolver cr = ctx.getContentResolver(); Cursor c = cr.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,new String[]{ BaseColumns._ID },MediaColumns.DATA + "=?",new String[]{ fn },null); if(c!=null) { try{ if(c.moveToNext()) { long id = c.getLong(0); Bitmap thumbnail = MediaStore.Images.Thumbnails.getThumbnail(cr,id,MediaStore.Images.Thumbnails.MINI_KIND,null); } }finally{ c.close(); } }