忘记了从哪获取的方法:
/**
* 设置提示音
*/
public static void remindVoice() {
YBTLog.e(TAG, "语音提醒呀");
boolean newMessageReminder = SettingUtil.isNewMessageReminder();
if (!newMessageReminder) {
return;
}
boolean isRemingNight = SettingUtil.isNewMessageReminderInNight();
if (!isRemingNight) {
//夜间不提醒
YBTLog.e(TAG, "设置的夜间不提醒");
return;
}
boolean newMessageVibrationReminder = SettingUtil.isNewMessageVoiceReminder();
if (!newMessageVibrationReminder) {
YBTLog.e(TAG, "设置的语音不提醒");
return;
}
AudioManager audioManager = (AudioManager) YBTApplication.getContext().getSystemService(Context.AUDIO_SERVICE);
if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
YBTLog.e("TAG", "已经调成静音");
return;
}
if (ringtone == null) {
Uri notificationUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
ringtone = RingtoneManager.getRingtone(YBTApplication.getContext(), notificationUri);
if (ringtone == null) {
YBTLog.d(TAG, "cant find ringtone at:" + notificationUri.getPath());
return;
}
}
if (!ringtone.isPlaying()) {
//String vendor = Build.MANUFACTURER;
ringtone.play();
// for samsung S3, we meet a bug that the phone will
// continue ringtone without stop
// so add below special handler to stop it after 3s if
// needed
// if (vendor != null && vendor.toLowerCase().contains("samsung")) {
// Thread ctlThread = new Thread() {
// public void run() {
// try {
// Thread.sleep(3000);
// if (ringtone.isPlaying()) {
// ringtone.stop();
// }
// } catch (Exception e) {
// }
// }
// };
// ctlThread.run();
// }
}
}
————————————————