Hello, Hashcode family.
I am a student who is learning by making a wake-up call application
Don't you know what you're going to do on your phone before you go to bed, in ring tone/vibration/silence mode?
So, assuming that the alarm goes off the next morning (when you call the activity in AlarmManager),
AudioManager audioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
audioManager.setSpeakerphoneOn(true);
audioManager.setRingerMode(audioManager.RINGER_MODE_NORMAL);
After switching to RINGER_MODE_NORMAL (after switching to ringtone mode)
Intent = getIntent(); //Uri value
Urrington Uri = int.getParcelableExtra ("Lyington");
final Ringtone ringtone = RingtoneManager.getRingtone(this, ringtoneUri); // Create a ringtone with the received Uri
ringtone.play();
I got the ringtone value from the previous activity and played ringtone.
I can switch to ringtone mode, but I can't hear ringtone.
For your information, if the alarm rings while waiting in the ringtone mode in the first place, the ringtone will play well.
What's the problem?
android ringtone android-audiomanager
In my test environment (Nexus Lollipop), when the stream type of ringtone is set as an alarm in silent mode, it plays normally. (You have not switched the ringtone mode through Audio Manager.) Test with the following sample code.
Uri uri = RingtoneManager.getActualDefaultRingtoneUri(getContext(), RingtoneManager.TYPE_RINGTONE);
Ringtone ringtone = RingtoneManager.getRingtone(getContext(), uri);
if (ringtone != null) {
ringtone.setStreamType(AudioManager.STREAM_ALARM);
ringtone.play();
}
© 2024 OneMinuteCode. All rights reserved.