I am new to Android development, and I am working on a media player app as a learning experience. I am currently trying to add a menu view that utilizes album art in a gridview. Here is my code:
public class coverMenu extends Activity {
private Cursor audioCursor;
public String artistInput;
private static final String TAG = "coverMenu";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.cover);
Bundle data = this.getIntent().getExtras();
String artistKey = data.getString("artistPass");
Toast.makeText(this, artistKey, Toast.LENGTH_LONG).show();
audioCursor = getContentResolver().query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, null,
MediaStore.Audio.Albums.ARTIST + "='" + artistKey + "'", null,MediaStore.Audio.Albums.ALBUM + " ASC");
startManagingCursor(audioCursor);
String[]from = new String[]{MediaStore.Audio.Albums.ALBUM_ART};
int[] to = new int []{android.R.id.text1};
ListAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1,
audioCursor, from, to);
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(mAdapter);
My problem is that the grid item now lists the path to the art, but does not show it. Can anyone help me by explaining how to parse this into a bitmap and send it to the gridview?
I have spent some time looking at the stock Android music player, but cannot find a simple solution to this.
Any help is appreciated.
[Latest Debug:]
DalvikVM[localhost:8615]
Thread [<3> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2496
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2512
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1863
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4363
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
Thread [<13> Binder Thread #2] (Running)
Thread [<11> Binder Thread #1] (Running)
Thread [<15> Binder Thread #3] (Running)