中靜音,也可以響鈴,即使鈴聲靜音也可以響鈴嗎?如果是的話,如何。另外,我可以將其音量設置爲介於兩者之間的某個值,而不僅僅是maxvolume?在此先感謝即使鈴聲在android
for (SmsMessage msg : messages) {
if (msg.getMessageBody().contains("firealert")) {
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if(alert == null){
// alert is null, using backup
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if(alert == null){
// alert backup is null, using 2nd backup
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
}
}
Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(), alert);
AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
int maxVolumeAlarm = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
int maxVolumeRing = audioManager.getStreamMaxVolume(AudioManager.STREAM_RING);
audioManager.setStreamVolume(AudioManager.STREAM_ALARM, maxVolumeAlarm,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
audioManager.setStreamVolume(AudioManager.STREAM_RING, maxVolumeRing,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
r.play();
Toast.makeText(context.getApplicationContext(), "alarm started", Toast.LENGTH_LONG).show();
}//end if
}//end for
「即使鈴聲靜音,是否可以響鈴?」如果用戶選擇在手機上關閉音量,則不應該試圖超越他們的意願。相反,在您的應用中創建一個界面,允許用戶在_they決定打開此特定功能時將除您以外的所有其他通知靜音。 (我每晚使用類似的方法。) – Sam
哈哈,我只是認爲這是可能的 –
即使鈴聲模式設置爲靜音/振動,某些供應商也不會使鬧鐘靜音。由供應商決定,所以我懷疑你會在所有Android設備上獲得相同的行爲。 – Michael