android - I want change the volume of ringertonevolume -


i used code adjust volume didn't work

int volume=23; audio.setstreamvolume(audiomanager.stream_ring,volume, audiomanager.flag_play_sound|audiomanager.flag_allow_ringer_modes);} 

you should not set volume 23 instead should first make call getstreammaxvolume(streamtype) max volume possible streamtype in case ringer's volume.

for example, set ringer's volume max this!

audiomanager.setstreamvolume(audiomanager.stream_ring, audiomanager.getstreammaxvolume(audiomanager.stream_ring), flag_allow_ringer_modes|flag_play_sound); 

updates

    int streammaxvolume = audiomanager.getstreammaxvolume(audiomanager.stream_ring);     toast.maketext(this, integer.tostring(streammaxvolume), toast.length_long).show(); //i got 7     audiomanager.setstreamvolume(audiomanager.stream_ring, streammaxvolume, audiomanager.flag_allow_ringer_modes|audiomanager.flag_play_sound); 

ok. @ home can try out codes. here can see, streammaxvolume gives me integer of 7. if try set 23 way much. possible values can use in setstreamvolume in case is

0, 1, 2, 3, 4, 5, 6, 7 lowest <-----> highest

//set lowest -> audiomanager.setstreamvolume(audiomanager.stream_ring, 0, audiomanager.flag_allow_ringer_modes|audiomanager.flag_play_sound);  //set loudest -> audiomanager.setstreamvolume(audiomanager.stream_ring, 7, audiomanager.flag_allow_ringer_modes|audiomanager.flag_play_sound); 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -