I've got a fragment where I'm recording audio, I want to pause the recording when a user presses the home key, but continue to record on a rotation.
In onPause, onStop or some other method that gets called, how can I differentiate between when the user has pressed home, or whether the fragment is being closed down because of a rotate?
I've looked into listening for the home key press, but everything I find says that isn't supported/won't work/can't do it.
I've tried using an OrientationEventListener, but it seems to get called nonstop, and if I'm looking for 0, 90, 180, and 270, my code still gets run if orientation goes from 1 to 0.
There has to be some way to differentiate that!? Any ideas?
EDIT is this my best option? --> http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange
EDIT
When I press the home button, I need to stop recording in onPause or onStop. When I rotate the device, I need to continue recording through those methods. So I need something I can check in those methods or before that tells me whether this is a home press or a rotation.
SOLUTION
I ended up just locking the orientation of the fragment when it's started and not allowing rotation. Not ideal, but more ideal than any other solution.