Android detect which ringtone is actually playing (Ringtone.isPlaying problem)

巧了我就是萌 提交于 2019-12-01 09:25:43

If you look at the source of Ringtone you can see that the isPlaying() method only cares about that particular instance of Ringtone.

When you call getRingtone() from RingtoneManager() it creates a new Ringtone object (source). So this will not be the same Ringtone object used to play a sound when someone calls (if Ringtone objects are used to do that) so isPlaying() will always return false in your case.

isPlaying() will only ever return true if you have called play() on that specific Ringtone object.

As each application creates its own MediaPlayer objects I don't think you can monitor which sounds other applications are currently playing.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!