您好,我想知道如何设置自定义警报音。

这是我的代码:

RingtoneManager.setActualDefaultRingtoneUri(
                    this,
                    RingtoneManager.TYPE_ALARM,
                    newUri
                    );


它适用于通知/声音,但不适用于警报(:S)?

提前致谢

最佳答案

您可以使用此代码

Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
 if(alert == null){
     // alert is null, using backup
     alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
     if(alert == null){  // I can't see this ever being null (as always have a default notification) but just incase
         // alert backup is null, using 2nd backup
         alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
     }
 }

10-08 14:49