Sorry if this has already been answered, but I can\'t specify my question very well. I have an activity that needs a song file from your device, and I want it when I press a
Slight Correction to 2Dee's answer:
Intent audiofile_chooser_intent;
audiofile_chooser_intent = new Intent();
audiofile_chooser_intent.setAction(Intent.ACTION_GET_CONTENT);
audiofile_chooser_intent.setType("audio/*");
ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0,
0, view.getWidth(), view.getHeight());
startActivityForResult(Intent.createChooser(audiofile_chooser_intent, getString(R.string.select_audio_file_title)), RQS_OPEN_AUDIO_MP3, options.toBundle());
Toast("File Chooser initiated..");
Intent inside of OnClick listener method to start FileChooser Activity/Dialog
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == RQS_OPEN_AUDIO_MP3) {
Uri audioFileUri = data.getData();
String MP3Path = audioFileUri.getPath();
Toast(MP3Path);
}
}
}
OnActivityResult method for obtaining the FilePath of selected file for subsequent use