user1982396
user1982396

Reputation:

How to start, stop playing sound (ringtone) : Android

I started playing sound by using: (Working)

RingtoneManager.getRingtone(this, Uri.parse(callerRing)).play();

And trying to stop playing sound using: (Not working)

ringtoneManager.stopPreviousRingtone();

Any help regarding this problem will be much appreciated.

Thanks

Upvotes: 1

Views: 3395

Answers (1)

user1982396
user1982396

Reputation:

Ok. I got answer for my own question. So I want to share it with you guys.

  1. Create instance of Ringtone as:

    Ringtone ringtone;
    
  2. Get ringtone from RingtoneManager using Uri:

    ringtone = RingtoneManager.getRingtone(this, Uri.parse(ringtone_uri));
    
  3. Start playing ringtone

    ringtone.play();
    
  4. Stop playing ringtone

    ringtone.stop();
    

Thats all. Thank you

Upvotes: 5

Related Questions