如何播放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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章