我需要测试不同的闹钟铃声,我需要它自动化。
如何以编程方式设置自己的警报铃声和振动设置?
public void ringAlarm(int addtime){
Calendar calendar = Calendar.getInstance();
Intent openNewAlarm = new Intent(AlarmClock.ACTION_SET_ALARM);
openNewAlarm.putExtra(AlarmClock.EXTRA_HOUR, calendar.get(Calendar.HOUR_OF_DAY));
openNewAlarm.putExtra(AlarmClock.EXTRA_MINUTES, calendar.get(Calendar.MINUTE)+addtime);
openNewAlarm.putExtra(AlarmClock.EXTRA_SKIP_UI,true);
startActivity(openNewAlarm);
}
我正在测试它。但是我需要完全不同的铃声,不仅仅是设置默认铃声。
public void testAlarmStock(){
Uri uri = Uri.parse("content://media/internal/audio/media/54");
RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_ALARM, uri);
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
mActivity.ringAlarm(1);
}