12

My application is randomly pausing (going into the onPause method) then resuming (going into the onResume method) when I'm not even touching the screen. In logcat, there is no indication what is causing the pause and resume. This only happens on a Galaxy Tab 7" and not on a Motorola Xoom or HTC Legend.

How can I determine the reason for a pause?

Amandeep Grewal
  • 1,801
  • 3
  • 19
  • 30
  • 1
    What do you mean by "pause"? Is onPause() being called or is the app locking up and resuming? – DeeV Jul 18 '11 at 15:32
  • onPause is being called. – Amandeep Grewal Jul 18 '11 at 15:33
  • 1
    if the screen turns off, onPause will be called. If the screen is not turning off and just happens randomly, I'm not sure why. – dymmeh Jul 18 '11 at 15:38
  • What do you mean by randomly? onPause is called when an activity is going to the background. – aromero Jul 18 '11 at 15:50
  • But it doesn't go into the background. It's still in the foreground, it immediately resumes (calling onResume) – Amandeep Grewal Jul 18 '11 at 15:56
  • What is the *actual* problem with this pause/resume cycle? The documentation states that the app may be paused at any time... – vidstige Jul 18 '11 at 16:51
  • 1
    Well I'm developing an OpenGL application, so onPause, it loses the OpenGL context, and on onResume I reload the textures from file. The problem is that it's randomly pausing and resuming causing the screen to have to reload the textures, which is undesirable. – Amandeep Grewal Jul 18 '11 at 17:04
  • 1
    I have the very same problem . onPause is triggered 5 seconds after launching the activity, and a few ms after, onResume is called again. I will now start to monitor the timestamp – Advanced Oct 15 '16 at 10:01

1 Answers1

8

You stated that it only happens only on the Galaxy Tab. I would hypothesize there is another app running on the device that frequently adds an invisible overlay. If this overlay is on the foreground, it would trigger the onPause() in your app.

You can use Android Instrumentation to monitor Activity launches by the use of ActivityMonitor. I believe you can even use it to prevent certain Activity from launching.

ming_codes
  • 2,870
  • 25
  • 24
  • That would be a pretty malicious application, wouldn't it? This tablet is a development device, only used at work, so random apps aren't being installed constantly. – Amandeep Grewal Jul 18 '11 at 17:11
  • Actually you may be onto something. In logcat, between my last logged line and onPause, this happens: `I/ActivityManager( 2492): Starting activity: Intent { flg=0x10000000 cmp=com.google.android.apps.maps/com.google.googlenav.login.AndroidLoginActivitySdk5 (has extras) }` What is this? – Amandeep Grewal Jul 18 '11 at 17:39
  • I just edited my answer. I never used Instrumentation myself, so..sorry I couldn't be more of a help. – ming_codes Jul 18 '11 at 17:57
  • It looks like it's possibly trying to get location information in a weird way? – Rob Jul 18 '11 at 18:09
  • 2
    Thanks for the help. Restarting the device worked. I think it was trying to get a location, and perhaps was trying to show an error window, but the error window errored and didn't show, being 'invisible' causing my Activity to pause and resume in secession. – Amandeep Grewal Jul 18 '11 at 19:11