Unexpected resume of “package name” while already resumed in ''package name" Error in Android

笑着哭i 提交于 2019-12-20 10:24:52

问题


If changing the orientation of my phone or the emulator I get the following output in LogCat:

04-09 11:55:26.290: INFO/WindowManager(52): Setting rotation to 1, animFlags=0
04-09 11:55:26.300: INFO/ActivityManager(52): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/1 nav=3/1 orien=2 layout=18}
04-09 11:55:26.460: INFO/UsageStats(52): Unexpected resume of client while already resumed in client
04-09 11:55:26.579: INFO/SearchPosition(807):  Activity is paused
04-09 11:55:26.689: INFO/SearchPosition(807):  Activity is resuming

SearchPosition is the activity that is displayed. Activity is paused is written in the onPause Method and Activity is resuming in the onResume method of the activity.

I googled a little bit for the error message but I don't fully understand the meaning of it. I think it could mean that the old Activity is not properly destroyed after changing the screen orientation.

Is this correct? If yes what causes the error? If this is not correct? What is the meaning of this output?


回答1:


Add this into the the activity declaration in your manifest.xml:

android:configChanges="orientation"

Example:

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

https://developer.android.com/guide/topics/manifest/activity-element.html#config

For Devices with QWERTY keyboard

android:configChanges="keyboardHidden|orientation"



回答2:


Example usage of android:configChanges="orientation" in AdroidManifest.xml file:

 <activity android:name=".Sound"
            android:configChanges="orientation"
                  android:label="@string/app_name" android:debuggable="true" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>



回答3:


I stumbled here first and after I read the link provided by leventix in his comment I can't help but think that both of the answers are actually wrong. Then I found the earlier question 3851363 which is about the same issue. The message is benign.

Correct me if I'm wrong, but I understood that the config option android:configChanges="orientation" should only be used when you want to handle the config changes yourself and not go through the typical onDestroy/onCreate cycle.

The android-8 seems to spawn the error in question needlessly in normal circumstances when the orientation changes.



来源:https://stackoverflow.com/questions/2606470/unexpected-resume-of-package-name-while-already-resumed-in-package-name-err

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!