Skip to content Skip to sidebar Skip to footer

Play Random Sound File On Button Press - Android

I am a beginner, I'm trying to make a very simple app, one button and 4 .ogg files in the assets folder, that button would play random file from the above mentioned. I have only on

Solution 1:

remove import android.R; from imports and import your on project R file . or use

descriptor = MainActivity.this.getAssets().openFd(mediaFile);

instead of

descriptor = MainActivity.this.getAssets().openFd("audioogg/"+mediaFile);

Post a Comment for "Play Random Sound File On Button Press - Android"