Search code examples
androidringtone

Setting random ringtone for incoming call


I am new to android application development. I need a solution for setting random ringtone for incoming call.

If the incoming call is coming for the first time my first ringtone which i was selected to be the default ringtone. for the second incoming call the ringtone must be changed. like this for third call also. after that for the fourth call again the first ringtone will be the default ringtone.

Like a shuffle way. I Need a programmatic solution for the shuffle way rotation of a ringtone.

I have a solution for setting the default ringtone. once if i set it as a default ringtone how can i add this it into the list. Three times i am selecting the ringtone from sdcard, and set it as a default ringtone. Any solution for setting three songs together as a one default ringtone.

Please help me to do it. Thanks in advance.


Solution

  • first create random no's by using Random() function

    Random rng = new Random(); 
    Integer next = rng.nextInt(20) ; // you can change this count.
    

    depending on this number you can set the ringtone