Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off all sounds and vibration via Android API

Tags:

android

I'm building an Android app, and I'm trying to disable all sounds and vibration of the device when the app starts.

I'm a newbie so I cannot find how to do that.

Any idea?

Thanks in advance.

like image 785
ferran Avatar asked May 01 '11 11:05

ferran


2 Answers

Thanks! :) I reply myself to complete the answer:

AudioManager aManager=(AudioManager)getSystemService(AUDIO_SERVICE);
aManager.setRingerMode(aManager.RINGER_MODE_SILENT);
like image 101
Ferran Avatar answered Nov 09 '22 19:11

Ferran


Check this here and take a look at public void setRingerMode (int ringerMode) with the RINGER_MODE_SILENT option.

like image 30
Haphazard Avatar answered Nov 09 '22 21:11

Haphazard