Change Default Notification Ringtone on Android -
i'm trying change notification ringtone within app. far can notification ringtones show, , select 1 of them, it's not changing it. i'm using far:
sharedpreferences settings = preferencemanager.getdefaultsharedpreferences(this); uri notification = uri.parse(settings.getstring("timersound", ringtonemanager.getdefaulturi(ringtonemanager.type_notification).tostring())); intent intent = new intent(ringtonemanager.action_ringtone_picker); intent.putextra(ringtonemanager.extra_ringtone_type, ringtonemanager.type_notification); intent.putextra(ringtonemanager.extra_ringtone_title, "select alert tone"); intent.putextra(ringtonemanager.extra_ringtone_existing_uri, notification); intent.putextra(ringtonemanager.extra_ringtone_show_silent, false); startactivityforresult(intent, 5);
you can change notification ringtone following code
//new ringtone uri uri nuri = uri.parse(""); //change notification ringtonemanager.setactualdefaultringtoneuri(this,ringtonemanager.type_notification, nuri);
if u want change ringtone sound can using following code
audiomanager audio = (audiomanager) getsystemservice(context.audio_service); audio.setringermode(audiomanager.ringer_mode_normal); (int volumetype : (new int[] { audiomanager.stream_system, audiomanager.stream_ring,audiomanager.stream_notification,audiomanager.stream_alarm })) { int maxvolume = audio.getstreammaxvolume(volumetype); audio.setstreamvolume(volumetype, maxvolume, audiomanager.flag_play_sound | audiomanager.flag_vibrate); audio.setstreammute(volumetype, false); audio.setvibratesetting(volumetype, audiomanager.vibrate_setting_on);
thank you
Comments
Post a Comment