Reputation: 364
hey i checked out a few questions and almost all of the questions were related to internet and mostly included methods like openConnection()and getInputStream() but mine is related to Media store so i am asking this question again here... I am able to get the Album URI by using media store and cursor but i do not know how to proceed further thanx in advance.
i tried
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);
but didn't help
Edit mediastore part.......
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);
one such URI:"/storage/sdcard0/Android/data/com.android.providers./media/albumthumbs/138216121805
Upvotes: 2
Views: 2597
Reputation: 45493
The easiest solution is to use a ContentResolver
:
InputStream is = context.getContentResolver.openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(is);
Or, a shortcut:
Bitmap bitmap = MediaStore.Images.Media.getBitmap(context.getContentResolver(), uri)
The context
variable can be an Activity
, Service
, application context etc.
Upvotes: 2
Reputation: 874
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(), imageUri);
Upvotes: 2