默认“哔哔”警报铃声

时间:2015-06-10 14:17:05

标签: android ringtone

在Andrid手机上是否有一些默认,安全使用,“beep beep”-styled铃声?

我有以下代码

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

它播放闹钟铃声,在早上唤醒我,这是一些舒缓的音乐。但我需要更多惊人的

当然,我可以将一些声音文件打包到apk,但我更喜欢使用设备上已有的声音。

1 个答案:

答案 0 :(得分:1)

在这里查看我的答案:

How do I access Android's default beep sound?

<?php
    $sql = mysql_query("SELECT name FROM competency ");
    //$row = mysql_fetch_array($sql);

    while($row = mysql_fetch_array($sql))
    {

    $focus=explode(",",$row['name']);
    ?>

    <input type="checkbox" name="focus[]" value="Art" <?php if(in_array("Comp",$focus)) { ?> checked="checked" <?php } ?> >
    <input type="checkbox" name="focus[]" value="Mathematics" <?php if(in_array("Mathematics",$focus)) { ?> checked="checked" <?php } ?> >
    <input type="checkbox" name="focus[]" value="Dance" <?php if(in_array("Dance",$focus)) { ?> checked="checked" <?php } ?> >
    <?php
    }
    ?>

这是一种列出设备中所有通知声音的方法

try {
    Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), notification);
    r.play();
} catch (Exception e) {
    e.printStackTrace();
}
找到'Helium'铃声后,使用它的Uri播放它:

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;
}