Instead of tracking a flag for the power button press, why not keep a flag for when you turn it off? That way if it was turned off for any other reason, it won't do anything.
Edit: Another idea...
What you could do is track the last time the ACTION_SCREEN_OFF
intent was fired. If the time is less than a certain threshold(0.05s?) from when your onSensorChanged
is called, you can just disregard(or at least not turn it back on).