Determine Reason for Android Pause
Asked Answered
K

1

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?

Katekatee answered 18/7, 2011 at 15:28 Comment(8)
What do you mean by "pause"? Is onPause() being called or is the app locking up and resuming?Ildaile
onPause is being called.Katekatee
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.Doloritas
What do you mean by randomly? onPause is called when an activity is going to the background.Heald
But it doesn't go into the background. It's still in the foreground, it immediately resumes (calling onResume)Katekatee
What is the actual problem with this pause/resume cycle? The documentation states that the app may be paused at any time...Scamp
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.Katekatee
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 timestampShantelleshantha
U
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.

Urion answered 18/7, 2011 at 17:5 Comment(5)
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.Katekatee
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?Katekatee
I just edited my answer. I never used Instrumentation myself, so..sorry I couldn't be more of a help.Urion
It looks like it's possibly trying to get location information in a weird way?Negus
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.Katekatee

© 2022 - 2024 — McMap. All rights reserved.