开发者

how do i view methods/step through code during orientation change in android

I have a simple WebView application which takes some time to load up when i change the orientation. In order to optimise i would like to get an understanding of the processes involved when changing orientation. I added dummy activity lifecycle methods with text being sent to logcat using the Log.d method. i however can not see any of these methods being used when i change the orientation.

I did a bit of digging and apparently i can also override the behaviour of the orientation configuration by using onConfigurationChanged, I coded the onConfigurationChanged method with some logcat statements but the program does not appear to go through this method as well.

Can you tell me how do i view the methods involved in configuration change so that i can optimise my code. as per this "article" configuration change should result in onDestroy being called, followed by onCreate. I cant see the onDestroy method e开发者_如何学Pythonxecuted, instead the program stops at onStop and does not appear to proceed further.

i checked in the logcat and each time i changed the orientation the WindowManager followed by the ActivityManager is fired.

can you guys tell me how to view the transitions? is there any setting i need to set someplace?


Android Baby, Try adding OnPause and OnResume overridden methods and add your breakpoints to those methods. They will be definitely called on Orientation changes.


Have you added the android:configChanges to your manifest file?
Here the documentation says onConfigurationChanged will be called only if you have android:configChanges="orientation" in the manifest file. Otherwise Android itself will handle all config changes.


If, as described in the article you refer to, you have put the following line in your manifest:

android:configChanges="orientation|keyboardHidden"

then your activity won't execute onPause/Stop/Destroy as it finishes in one orientation and then restarts in the other, running through onCreate/Start/Resume.

This is because you have told the application that you will handle the orientation changes yourself when you insert that line. If you write an override for onConfigurationChanged(..), then it will run through that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜