Reputation: 1
Is it possible to vibrate phone with RINGER_MODE_NORMAL? If the audio profile is in 'Ring + No vibration' mode.
If you can, please help in details code. Thanks in advance.
Upvotes: 0
Views: 821
Reputation: 8004
You can use a switch
and check the current ringer with getRingerMode
and do what you want next; setRingerMode
switch( audio.getRingerMode() ){
case AudioManager.RINGER_MODE_NORMAL:
audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
case AudioManager.RINGER_MODE_SILENT:
audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
case AudioManager.RINGER_MODE_VIBRATE:
break;
}
Also do not forget if you have not already to add permission in your manifest file ...
<uses-permission android:name="android.permission.VIBRATE"/>
UPDATE
You can't set both at the same time, one or the other. Also you changed what you wanted according to original question, when you do this it can make thing's more confusing. Below is more info about setRingerMode
Upvotes: 1
Reputation: 469
AudioManager mAudioManager;
onCreate() {
mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
// now for setting it in Vibration mode :
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
}
tis is the code for setting the phone to VIBRATION mode. Rest you have to check the current state and everything. for full code go here
Upvotes: 1