mt6735 如何使会议模式下,将闹钟的响铃提示改为震动提示
时间:10-02
整理:3721RD
点击:
[DESCRIPTION]
设置-情景模式-会议,开启一个闹钟,等闹钟时间到时,仍然是响铃提示,如何将其修改为震动而不响铃?
[SOLUTION]
修改packages\apps\DeskClock\src\com\android\deskclock\alARMs\AlarmKlaxon.Java 文件中,
将startAlarm(...)修改为如下:
private static void startAlarm(Context context, MediaPlayer player) throws IOException
{
Log.v("startAlarm, check StreamVolume and requestAudioFocus");
AudioManager audioManager = (AudioManager)
context.getSystEMService(Context.AUDIO_SERVICE);
// do not play alarms if stream volume is 0 (typically because ringer mode is silent).
if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) {
if(audioManager.getStreamVolume(AudioManager.STREAM_RING) != 0){
player.setAudioStreamType(AudioManager.STREAM_ALARM);
player.setLooping(true);
player.prepare();
audioManager.requestAudioFocus(null,
AudioManager.STREAM_ALARM, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
player.start();
Log.d("Play successful, StreamVolume != 0");
}
// add start
else{
boolean bShouldVibrate = false;
bShouldVibrate = audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER);
if (bShouldVibrate) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) {
Log.v("vibrator starts,and vibrates:" );
vibrator.vibrate(VIBRATE_PATTERN, 0);
}
}
}
// add end
}
}
设置-情景模式-会议,开启一个闹钟,等闹钟时间到时,仍然是响铃提示,如何将其修改为震动而不响铃?
[SOLUTION]
修改packages\apps\DeskClock\src\com\android\deskclock\alARMs\AlarmKlaxon.Java 文件中,
将startAlarm(...)修改为如下:
private static void startAlarm(Context context, MediaPlayer player) throws IOException
{
Log.v("startAlarm, check StreamVolume and requestAudioFocus");
AudioManager audioManager = (AudioManager)
context.getSystEMService(Context.AUDIO_SERVICE);
// do not play alarms if stream volume is 0 (typically because ringer mode is silent).
if (audioManager.getStreamVolume(AudioManager.STREAM_ALARM) != 0) {
if(audioManager.getStreamVolume(AudioManager.STREAM_RING) != 0){
player.setAudioStreamType(AudioManager.STREAM_ALARM);
player.setLooping(true);
player.prepare();
audioManager.requestAudioFocus(null,
AudioManager.STREAM_ALARM, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
player.start();
Log.d("Play successful, StreamVolume != 0");
}
// add start
else{
boolean bShouldVibrate = false;
bShouldVibrate = audioManager.shouldVibrate(AudioManager.VIBRATE_TYPE_RINGER);
if (bShouldVibrate) {
Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator != null) {
Log.v("vibrator starts,and vibrates:" );
vibrator.vibrate(VIBRATE_PATTERN, 0);
}
}
}
// add end
}
}
sgrs yetimo,9y.p/u[|_\