How do I stop the currently playing ringtone?

前端 未结 3 597
野趣味
野趣味 2021-02-02 02:38

I\'m writing an app that sometime fires reminders that are supposed to play ringtones. I can start the ringtone OK, but can\'t stop it. I have a dismiss method in my fragment th

3条回答
  •  面向向阳花
    2021-02-02 03:36

    Create RingtoneManager object using Application Context like this

    RingtoneManager ringMan = new RingtoneManager(getApplicationContext());
        ringMan.stopPreviousRingtone();
    

    and RingTone object also create like this only.

    mRingTome = RingtoneManager.getRingtone(getApplicationContext(), notification);
                mRingTome.play();
    

    It is working for me.

提交回复
热议问题