I am trying to play an audio file present in res/raw directory using the default audio player from my app.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(String.format("android.resource://%s/%s/%s",getContext().getPackageName(),"raw","fade")), "audio/*");
startActivity(intent);
However, every time I am getting exception:
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=android.resource://com.example.android.punjabi/raw/fade typ=audio/* launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } }
I have tried out the ways mentioned in here:
Get URI of .mp3 file stored in res/raw folder in android
It still gives me the same exception.
Any help please. I don't want to use the MediaPlayer class to play the audio. I want to use the default audio player on the phone to play it.