After many years of trust in the life cycle, I did a little work. Now I am not surprised.
I know and read a lot about what onStopcannot be called up, etc.
I created a simple application with two Activites and a custom application class. I put Log.d () in every callback I could find and play on the Galaxy S2 with 4.1 on it. Action A starts when it starts and onResumeActivity B starts in it . Activity B has a button that creates a Nullpointer, but otherwise does nothing.
Now I'm worried / confused:
if I create a null pointer on the buttonclick button, the application crashes and NO callback does not occur in any of the operations
if I press the power button and turn off the screen, the action will be restarted if the display mode (portrait or landscape) of the activity does not correspond to the initial orientation of the device. I know this and how I can override it, but if it destroys and restarts my activity, it calls onPauseand isFinishing()returns false, but the action ends and restarts.
If the above does not occur, it is called only onPause, even if the application is no longer visible
starting another activity calls onPausein A, then creates B in onResume, and then calls onStopgroups A. Now I keep track of my actions in the .App class and if I unregister A in onPauseand register B in onResume, the millisecond will be broken where the activity is not registered. If I wanted to close a service when there was no activity, this will happen all the time. But if I unregistered in onStop(so that they overlap), he would never have been unregistered when the user presses the power button, and the service (or thread or something else) continues to work and discharge the battery power.
I have been working with android for quite some time now, and I am trying to achieve quite complex or allows a bulletproof design. But it’s almost impossible to keep track of what is happening with my activity.
powerdown Intent.ACTION_SCREEN_OFF, , . , onPause.
homebutton... onUserInteraction pause/stop
, APP ( ) . .App , onTerminate() , .
, ...
!