6

Several of my Android applications show the following type message in the logcat output:

I/UsageStats(   59): Unexpected resume of com.totsp.test while already resumed in com.totsp.test

In this case I created the default Hello World app by letting the ADT tool generate it, and it still gets this message. I am not doing anything special in onCreate and don't even have any other methods defined.

I realize this is an INFO level message, and it doesn't appear to hurt anything, but I was curious what was going on so I made a test application that keeps track of the onResume invocations. It is indeed re-resuming when this occurs. I'm wondering why this this occurs? While I haven't noticed a problem (other than these annoying log messages), it seems like it could be using more resources than necessary to do all this stuff an extra time.

I have searched and read a similar question here on SO, and the answer there seems dubious to me: Unexpected resume of "package name" while already resumed in ''package name" Error in Android. Specifically, no, you don't want to use android:configChanges="orientation" because that is just subverting the orientation tear down/resume, rather than fixing it. Even the documentation notes "this attribute should be avoided and used only as a last-resort" (http://developer.android.com/intl/de/guide/topics/manifest/activity-element.html#config).

Also I have seen thread in the Android dev group where Mr. Murphy says the "unexpected resume" is "benign": http://groups.google.com/group/android-developers/browse_thread/thread/567410dbfcc163c2.

I'll dig into the source when I get a chance, but I figured I would first just ask the all-knowing hivemind and see if someone already knows: why does this occur, and is it truly benign?

Community
  • 1
  • 1
Charlie Collins
  • 8,806
  • 4
  • 32
  • 41
  • I cited it as benign because I recalled that Dianne Hackborn had indicated it is benign. I can't quite find where I encountered that, though. – CommonsWare Oct 03 '10 at 20:54
  • One of the problems in android is that the various integrators didn't clean up benign error messages in shipping builds, so it takes some experience to know what is actually a problem. It's kind of like compiling someone else's code that generates lots of warnings... – Chris Stratton Oct 03 '10 at 23:44
  • @CommonsWare Yeah I thought I had seen that in the past too, but I couldn't find it today either. – Charlie Collins Oct 04 '10 at 00:08

2 Answers2

7

Don't worry about it, it is just a message from some internal state tracking that is not really a problem (hence it being INFO level). I'll make sure it is removed in the next platform version.

hackbod
  • 90,665
  • 16
  • 140
  • 154
0

My whole Activity flow changes every time this error comes,

but i have handled this by adding android:configChanges="orientation" in the activity in Manifest File.

<activity android:name=".YourActivity" android:label="@string/app_name" android:configChanges="orientation" android:screenOrientation="nosensor">

Hope this helps you

Arun
  • 3,406
  • 4
  • 30
  • 55
user723282
  • 15
  • 3
  • Your activity flow is probably changing due to your activity restarting on rotation. The android:configChanges="orientation" just prevents your activity from restarting when orientation changes, which means you'll have to handle any orientation-related changes yourself. – Steve Pomeroy Jun 09 '11 at 12:17
  • Yes, what Steve said. See my original question even for more about this: "Specifically, no, you don't want to use android:configChanges=orientation because that is just subverting the orientation tear down/resume, rather than fixing it. Even the documentation notes 'this attribute should be avoided and used only as a last-resort'." – Charlie Collins Jul 19 '11 at 22:35