Jared Snyder wrote:In my app I have an Activity called AlarmActivity that will start when a condition is met in MainActivity. When AlarmActivity starts, if CheckBoxPreference for vibrate is checked, I, of course, want vibration to start. I also have an onLongClickListener attached to a button that silences the alarm, so I would like to stop vibrating when the new Activity starts. Presently, vibrating starts when the AlarmActivity starts, regardless of CheckBoxPreference, and continues even after the new Activity starts onLongClick; until I exit out of the app entirely.
This is my AlarmActivity:
You call the vibrate function without ever checking the preference, so yes, if vibrates regardless of if the preference is on or off.
You should read the preference and put this in an if statement dependent on the preference's value.
Does the main activity silence the vibration? If not then you need to tell the vibration to stop here.