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 documentati开发者_开发技巧on 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?
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.
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
精彩评论