【发布时间】:2017-04-07 17:23:23
【问题描述】:
有没有办法以编程方式播放内置音效?我想在我的应用扫描NFC标签时播放NFC音效(成功音效和失败音效)。
【问题讨论】:
有没有办法以编程方式播放内置音效?我想在我的应用扫描NFC标签时播放NFC音效(成功音效和失败音效)。
【问题讨论】:
我只是从接受的答案中粘贴代码 - StackOverflow question to play Android Notification sound
try {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
r.play();
} catch (Exception e) {
e.printStackTrace();
}
【讨论】: