I have an activity that starts the Vibrator system service in its onCreate method, then when the user pushes a button it cancels the vibrator, then calls finish() to close the activity.
This activity is brought up via the AlarmManager, so when it gets closed it will return the user to whatever app they currently had open (not necessarily mine).
The problem I'm having is if my activity is in landscape mode, and the user is brought to a screen that doesn't support landscape (such as the home screen) when the activity closes, my application switches to portrait and calls onCreate() before actually closing my screen. So the steps causing this problem are as follows...
Currently the only way I can think of to rectify this is to make my activity only support portrait mode, but I'd like to avoid that if I can. Does anyone know a way in which I can prevent onCreate() from being called after I call finish()?
why dont you call method
onPause()
or onStop()
and inside this methods call vibrator.cancel()
onStop() always gets called when your app is not visible anymore.
check out this flowchart