Saturday, March 16, 2019

Android开发笔记-ch3.4.20 Activity


3.4.20 Activity

Diagram from Google android:
Note, when start a new activity within an activity, the current activity's onStop() may get called even after the new activity's onStart() get called. For example, in my EOB project, VideoViewActivity is used for playback both AD and media. When an AD activity is started during media playback, logcat shows:
03-15 22:15:10.085 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: Showing AD: eob_ad/YouNeedChair_V1.mp4
03-15 22:15:10.105 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: Media video onPause
03-15 22:15:10.125 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: AD video onStart
03-15 22:15:10.125 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: Play AD: eob_ad/YouNeedChair_V1.mp4
03-15 22:15:10.125 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: AD video onResume
03-15 22:15:10.455 3189-3199/org.mousedog.eobmedia W/MediaPlayer: info/warning (701, 0)
03-15 22:15:10.615 3189-3200/org.mousedog.eobmedia W/MediaPlayer: info/warning (3, 0)
03-15 22:15:10.615 3189-3214/org.mousedog.eobmedia W/MediaPlayer: info/warning (702, 0)
03-15 22:15:10.815 3189-3189/org.mousedog.eobmedia I/VideoViewActivity: Media video onStop
The media playback activity's onStop is called even after the AD onResume already invoked. So saving current position should be done inside onPause.

0 Comments:

Post a Comment