android播放系统默认的铃声

播放默认通知声音

/**
     * 播放系统默认提示音
     *
     * @return MediaPlayer对象
     *
     * @throws Exception
     */
    public void defaultMediaPlayer() throws Exception {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        Ringtone r = RingtoneManager.getRingtone(mContext, notification);
        r.play();
    }

播放默认来电铃声

/**
     * 播放系统默认来电铃声
     *
     * @return MediaPlayer对象
     *
     * @throws Exception
     */
    public void defaultCallMediaPlayer() throws Exception {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
        Ringtone r = RingtoneManager.getRingtone(mContext, notification);
        r.play();
    }
播放默认闹钟铃声
 /**
     * 播放系统默认闹钟铃声
     *
     * @return MediaPlayer对象
     *
     * @throws Exception
     */
    public void defaultAlarmMediaPlayer() throws Exception {
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
        Ringtone r = RingtoneManager.getRingtone(mContext, notification);
        r.play();
    }





你可能感兴趣的:(笔记)