Search code examples
androidxamarinlockingvolume

Service lowers volume even when volumes are on max


In my app I have an additional library for SIP calling, which on some phones (Huawei 5.1) locks volume to around 50% (or even less) for some reason and it keeps it like that for the whole phone volume meanwhile service is running.

I tried setting:

am.SetStreamVolume(Android.Media.Stream.Music,am.GetStreamMaxVolume(Android.Media.Stream.Music), 0);

And playing beeping noise with MediaPlayer/Soundpool. I also tried setting Microfone to

Mode.Ringtone / Mode.Normal,...

but the volume is still low when this library/service is running. Is there any other setting option possible that could override some setting in the library, because if I look current volumes, it's all on MAX (Media/Notification/Ringtone/...)?

In this library, you have to initialize sampleRate / buff size, which I do with getting default values from Android

String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);

Solution

  • Some companies add a volume limit to protect user. I met similar issue before on samsung note 4. I am not sure whether APP has the permission to break this limit(mostly not allow).
    In order to find the relative setting, please try this: Play music by the default music player, and press volume+. Keep volume up and then your phone may toast a dialog to tip you. And you can change this setting.

    Hope it works :)