android - How to disable increasing volume ring in Marshmallow programmatically? -


i want disable escalating/rising/increasing volume of ringtone on incoming call. know there's application disable increasing ring i'm android developer, cant see mobile ads stop phone's increasing volume ;)

i've tried way...

public class callreceiver extends broadcastreceiver {      context context;      public void onreceive(context context, intent intent) {         try {             this.context = context;             telephonymanager manager = (telephonymanager) context.getsystemservice(context.telephony_service);             manager.listen(new myphonestatelistener(), phonestatelistener.listen_call_state);                         } catch (exception e) {             e.printstacktrace();         }     }      private class myphonestatelistener extends phonestatelistener {         public void oncallstatechanged(int state, string incomingnumber) {                         audiomanager manager = (audiomanager) context.getsystemservice(context.audio_service);             if (state == 1 && manager.getringermode() == audiomanager.ringer_mode_normal) {                 log.e(getclass().getsimplename(), "incoming call : " + incomingnumber);                 manager.setstreamvolume(                     audiomanager.stream_ring,                     manager.getstreammaxvolume(audiomanager.stream_ring),                     flag_allow_ringer_modes | flag_play_sound                 );             }         }     } } 

when put 0 volume, phone state listener working. think setstreamvolume() not working against increasing volume when use 7 or manager.getstreammaxvolume(audiomanager.stream_ring) volume.

reference :


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -