In our application, we can add notification ringtone as we want. Here is the solution.
First of all we need to create a folder named raw in /res/ file. After creating the folder put your ringtone in raw folder.
Then put this code when you notify your notification.
SoundPool soundPool = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
int value = soundPool.load(context, R.raw.my_music, 1);
soundPool.play(value, 1, 1, 0, 0, 1);
//here put raw file to play
MediaPlayer myMediaPlayer= MediaPlayer.create(context, R.raw.my_music);
myMediaPlayer.prepare();
myMediaPlayer.start();
0 Comment(s)