0

I have seen a lot of questions about ringer mode. Nothing seems to give me a clue on the problem I am facing. I have set ringer mode to the normal RING mode for a service that gets started in the foreground. Unfortunately that doesnt seem to change the phone's ringer mode if it was on silent or vibrate in the first place. However, if put the same piece of code behind a button on an activity then it works.

The above described case happens only in Android 4.0.4 (ICS) but not in FR 2.2. Any clue on how to get around this? Here's my code:

AudioManager audioManager = (AudioManager) ctx.getSystemService(Context.AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL); 
Robert
  • 8,717
  • 2
  • 27
  • 34

2 Answers2

0

I have figured out why it didnt work on my phone. I had an other app called Flip Silent that interfered with the working of my app. After everytime I set the Audio Manager to ringer mode, it's service set it it back to the exisiting mode leading me to think it wasnt working.

it was difficult to debug as the logs didnt lead me in any direction. But a flicker on my home screen lead me to find this out. I uninstalled the flip silent app and everything worked!!

0

I also face the same problem so, I slove that this way.

int getMediaValue = audioManager.getStreamVolume(audioManager.STREAM_RING);
int setVolume = getMediaValue - 1;
// This was work for ring volume
audioManager.setStreamVolume(audioManager.STREAM_RING, setVolume, AudioManager.FLAG_SHOW_UI );

So you can try this way :)

imnhasan
  • 93
  • 1
  • 2
  • 10