Is there a way to play built-in sound effects programmatically? I want to play the NFC sound effect when my app scans an NFC tag (success sound effect and failure sound effect).
Im just pasting code from the accepted answer that is in - 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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With