Ok, so I'm very new to Android. My gf asked me to make a very simple application for her so that she could easily switch from vibration always, never to vibrate. This seemed to be a fairly simple task. So, I have a toggle button, and it changes the setting, but I always run into one big problem. He will not change between always and never. if I always install it, it will switch between always and only in silent mode, or if I configure it so that it never switches between them only in silent mode and never. Did I miss some obvious but tricky details? this is my exchange code.
public void onClick(View arg0) {
if (vibrateOn) {
vibrateOn = false;
adManag.setVibrateSetting (AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
adManag.setVibrateSetting (AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
} else {
vibrateOn = true;
adManag.setVibrateSetting (AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_ON);
adManag.setVibrateSetting (AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_ON);
}
Log.d (TAG, "after" + Integer.toString (adManag.getVibrateSetting (AudioManager.VIBRATE_TYPE_RINGER)));
}
source share