Tarik
Tarik

Reputation: 81711

Turn off ring tone temporarily

When someone calls, my app will turn off the ringing tone in order not to distract the user. So could you please tell me how to turn off the ringing sound in Android?

EDIT:

It seems I will need to use this one :http://developer.android.com/reference/android/media/Ringtone.html

Upvotes: 1

Views: 2246

Answers (1)

Tarik
Tarik

Reputation: 81711

I think I've found the solution. In case someone else needs it, I copy my solution here:

AudioManager manager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
manager.setRingerMode(AudioManager.RINGER_MODE_SILENT);

There is a manager class called AudioManager which controls the audios and such. And it has a instance method setRingerMode(int mode) which accepts a integer flag.

Once you're done with the silence, you can change the status of the ring tone by passing in this flag RINGER_MODE_NORMAL

Upvotes: 3

Related Questions