I've got a basic doorbell application, and I'm working out the last few kinks. One of the last ones I have is a vibrate function problem.
I've got an if-else statement which allows the phone to vibrate based upon a boolean. This works perfectly.
I want this function to be disabled while the phone is playing the sound I have.
I figure this would be done with an if-else statement, something like this:
if(dBell.isPlayingSound()) {
// No vibrate
} else {
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(500);
}
Either that, or based upon the timer I have set to change the picture, such as:
if(timer.hasNotExecuted) {
// No vibrate
} else {
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(500);
}
Here is my current if-else statement which makes the vibration toggle:
if (vibeOn) {
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(500);
} else {
// No vibration
}
I need to get the vibration toggle to occur when the boolean is true and when the timer isn't done (or when the sound is not playing). So perhaps something like this:
if(vibeOn && timer.hasFinished) {
Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
vibe.vibrate(500);
} else {
// No vibration
}
Or
if(vibeOn && dBell.isNotPlaying) {
...
Something like that. I'm not sure what to do. I think I have the basic idea, but I don't know the code to make it happen.
Help!
Thanks!
Nathan
Aucun commentaire:
Enregistrer un commentaire