如何播放Android通知声音 - How to play an android notification sound

问题:

I was wondering how I could play a notification sound without playing it over the media stream. 我想知道如何在不通过媒体流播放通知声音的情况下播放通知声音。 Right now I can do this via the media player, however I don't want it to play as a media file, I want it to play as a notification or alert or ringtone. 现在,我可以通过媒体播放器来执行此操作,但是我不希望它作为媒体文件播放,我希望它作为通知或警报或铃声播放。 heres an example of what my code looks like right now: 这是我的代码现在看起来像的一个示例:

MediaPlayer mp = new MediaPlayer();
mp.reset();
mp.setDataSource(notificationsPath+ (String) apptSounds.getSelectedItem());
mp.prepare();
mp.start();

解决方案:

参考一: https://en.stackoom.com/question/IdOQ
参考二: https://stackoom.com/question/IdOQ
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章