3

Is there some default, safe to use, "beep beep"-styled ringtone 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 the alarm ringtone which wakes me up at morning, which is some soothing music. But I need something more alarming.

Sure, I can pack some sound file to apk, but I'd prefer to use some sounds already available on devices.

Pitel
  • 5,334
  • 7
  • 45
  • 72

1 Answers1

1

Check my answer here:

How do I access Android's default beep sound?

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 notifications sound you have in 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 'Helium' ringtone, use its Uri to play it:

 Uri heliumUri = findHeliumUri();
 Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
 r.play();
Community
  • 1
  • 1
Mohammad Ersan
  • 12,304
  • 8
  • 54
  • 77
  • Well, notification will probably be more *beepy* than alarm, but it still plays my default notication sound. What I want, is to play eg. "Helium" (one of sound I found of most devices I have), and if it's nto there, play user's default notification sound. – Pitel Jun 10 '15 at 14:50