I'm trying to write a function which simply shows all of the music files (mp3) available in users phone (internal/external memory) and return the selected file with a callback "interface".
Here is what I have but I don't have the callback! * I use API 16 (JB 4.1) *
public void pickMusic() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI);
intent.setType("audio/*");
try {
getContext().startActivity(intent);
}
catch (Throwable e) {
Log.d(TAG, "pickMusic: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
If you know a better way of doing this please share. Thanks in advance.
Edit: I use a different API level! "startActivityForResult" don't show up for me, my application is a subclass of Application class.