I have an array in xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="sounds_array">
<item>R.raw.fart</item>
<item>R.raw.beep33</item>
</array>
</resources>
I want to create a media player to play these sounds from my raw folder.
mSoundsArray = mContext.getResources().obtainTypedArray(R.array.sounds_array);
mediaPlayer = MediaPlayer.create(mContext, mSoundsArray.getResourceId(0, -1));
mediaPlayer.start();
but istead of expected result I got an this error:
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffffffff
any idea how can I get resourceId from this array?