The default beep sound is "beep beep"

Is there a default, safe to use beep beep on Andrid phones?

I have the following code

final Ringtone alarm = RingtoneManager.getRingtone(getActivity(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM));
alarm.setStreamType(AudioManager.STREAM_ALARM);
alarm.play();

      

It plays an audible melody that will wake me up in the morning, which is some soothing music. But I need something more disturbing.

Of course, I can pack the sound file in apk, but I would rather use some of the sounds already available on devices.

+3


source to share


1 answer


Check out my answer here:

How to access default sounds for Android?

try {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
    r.play();
} catch (Exception e) {
    e.printStackTrace();
}

      




here is a way to list all the notification sounds you have on your device.

public Map<String, String> getNotifications() {
    RingtoneManager manager = new RingtoneManager(this);
    manager.setType(RingtoneManager.TYPE_NOTIFICATION);
    Cursor cursor = manager.getCursor();

    Map<String, Uri> list = new HashMap<>();
    while (cursor.moveToNext()) {
        String notificationTitle = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
        Uri notificationUri = manager.getRingtoneUri(cursor.getPosition());

        list.put(notificationTitle, notificationUri);
    }

    return list;
}

      

after finding the "Helium" melody, use its Uri to play it:

 Uri heliumUri = findHeliumUri();
 Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
 r.play();

      

+1


source







All Articles