Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change vibrate mode to ringer prgrammatically through audio manager

Tags:

android

I am making application where phone mode will changes from silent mode to ringer mode if the user sends an sms with some specific keyword. The application mainly works when user lost his cell somewhere in house and its on silent mode. My main question is how can i change the phone mode through audio manager ??

like image 566
Jasmeet Kaur Chauhan Avatar asked Jun 19 '12 10:06

Jasmeet Kaur Chauhan


2 Answers

set SILENT mode to Normal mode using AudioManager

AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);   

switch (am.getRingerMode()) {   
    case AudioManager.RINGER_MODE_SILENT:   
        Log.i("MyApp","Silent mode");
        am.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        break;   
}  
like image 132
ρяσѕρєя K Avatar answered Sep 18 '22 11:09

ρяσѕρєя K


try this:

AudioManager audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
like image 24
Vineet Shukla Avatar answered Sep 19 '22 11:09

Vineet Shukla