以编程方式设置默认闹钟声音 Android [英] Set default alarm sound programatically Android

查看:51
本文介绍了以编程方式设置默认闹钟声音 Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试定义默认的闹钟声音,但没有成功!我可以成功更改铃声和通知声音,但闹钟根本没有改变......我正在使用此代码作为闹钟:

I've been trying to define the default alarm sound but with no success! I can sucessfully change the ringtone and the notification sound but the alarm doesn't change at all... I'm using this code for the alarm:

RingtoneManager.setActualDefaultRingtoneUri(getActivity(), RingtoneManager.TYPE_ALARM, Uri.parse(uri+"/"+id));

非常感谢!

推荐答案

试试这个

 try {
            RingtoneManager.setActualDefaultRingtoneUri(getContext(),
                    RingtoneManager.TYPE_ALARM, newUri);
            Settings.System.putString(mCr, Settings.System.ALARM_ALERT,
                    newUri.toString());
            Toast.makeText(getContext(), "Done", Toast.LENGTH_SHORT).show();

        } catch (Throwable t) {

        }

这篇关于以编程方式设置默认闹钟声音 Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆