Search code examples
androidandroid-activitylifecycleonresumeonpause

Android 2.1.2, Device is locked but it seems onPause and onResume is called multiple times


I have an application which uses the MediaPlayer to play music. When I play music and lock my device it starts to call onPause and onResume in various periods of time, ( it's not the time of one track )

My log is like this:

07-11 10:08:50.933: INFO/Activity(9956): resume PlayerActivity
07-11 10:08:50.948: INFO/Activity(9956): pause PlayerActivity
07-11 10:08:56.300: INFO/Activity(9956): resume PlayerActivity
07-11 10:08:56.316: INFO/Activity(9956): pause PlayerActivity
07-11 10:09:21.839: INFO/Activity(9956): resume PlayerActivity
07-11 10:09:21.886: INFO/Activity(9956): pause PlayerActivity
07-11 10:09:27.003: INFO/Activity(9956): resume PlayerActivity
07-11 10:09:27.019: INFO/Activity(9956): pause PlayerActivity
07-11 10:18:49.738: INFO/Activity(9956): resume PlayerActivity
07-11 10:18:49.745: INFO/Activity(9956): pause PlayerActivity

Is this normal behaviour of the android Activity ? There where no buttons pressed or anything else done with the device.

Best regards


Solution

  • Yes this is the normal behavior of Android. Based on the action that is being performed, the method corresponding to the life cycle will be called. In each case you might have to override the appropriate method to get the result you require.