我试过
Bitmap bitmap=null;
MediaMetadataRetriever mmr = new MediaMetadataRetriever();
byte[] rawArt = null;
BitmapFactory.Options bfo=new BitmapFactory.Options();
mmr.setDataSource(string);
rawArt = mmr.getEmbeddedPicture();
bitmap=BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo);
但没有帮助
编辑媒体商店部分.......
columns = new String[]{ android.provider.MediaStore.Audio.Albums._ID,
android.provider.MediaStore.Audio.Albums.ALBUM,
MediaStore.Audio.Albums.ALBUM_ART };
cursor =
getActivity().managedQuery(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI,
columns, null, null, null);
if(cursor != null){
while(cursor.moveToNext()) {
SongDetails songs = new SongDetails();
songs.song= cursor.getString(1);
songs.Path=cursor.getString(2);
//songs.Album=cursor.getString(0);
//songs.Artist=cursor.getString(1);
songdetails.add(songs);
}}
list=(GridView)container.findViewById(R.id.grid_view);
adapter=new LazyAdapter( songdetails);
一个URI:"/storage/sdcard0/Android/data/com.android.providers./media/albumthumbs/138216121805
答案 0 :(得分:2)
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),imageUri);
答案 1 :(得分:2)
最简单的解决方案是使用ContentResolver
:
InputStream is = context.getContentResolver.openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(is);
或者,快捷方式:
Bitmap bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri)
context
变量可以是Activity
,Service
,应用程序上下文等。