Put Phone In Vibrate In Android Code
I am trying to activate vibrate in android but evrey time i press the button the app crash..... silet.setRingerMode(AudioManager.RINGER_MODE_VIBRATE) also i did the import thing.
Solution 1:
I'm taking a guess, but you declared:
public AudioManager silent;
Have you initialized it with:
AudioManagersilent= (AudioManager) getSystemService(AUDIO_SERVICE);
And you spelled silent
wrong here:
silent.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
//silet.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
Solution 2:
Try this code it will help you
AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
Need to add permission in AndroidManifest.xml
<uses-permissionandroid:name="android.permission.VIBRATE"/>
Enjoy!!!
Post a Comment for "Put Phone In Vibrate In Android Code"