[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]
 

* Here is test result about calling onXXX functions.

Starting -> Showing

+ onWindowAttributeChanged x N
+ onContentChanged
+ onCreate
+ onStart
+ onPostCreate
+ onTitleChanged
+ onResume
+ onPostResume
+ onAttachToWindow
+ onWindowFocusChanged

Portrait Landscape (without handling configuration changes directly)

+ onSaveInstanceState
+ onPause
+ onStop
+ onRetainNonConfigurationInstance
+ onDestroy
+ onWindowAttributeChanged x N
+ onContentChanged
+ onCreate
+ onStart
+ onRestoreInstanceState <---
+ onPostCreate
+ onTitleChanged
+ onResume
+ onPostResume
+ onAttachToWindow
+ onWindowFocusChanged

Incomming Call

+ onSaveInstanceState
+ onPause
+ onWindowFocusChanged
+ onStop

Call ended

+ onRestart
+ onStart
+ onResume
+ onPostResume
+ onWindowFocusChanged

* To handle configuration change directly.
- Add android:configChanges="keyboardHidden|orientation" at the Activity in AndroidManifest.xml
- Override onConfigurationChanged(Configuration newConfig) ..

* Using onSaveInstanceSteate/onRestoreInstanceState
onSaveInstanceSteate/onRestoreInstanceState is called very often. So, we would better to avoid writing additional code except for saving/restoring state. Especially, allocating memory in "onRestoreInstanceState" should be avoided, even if this is quite good place to initialize newly restarted or resumed activity. Putting these code in it, may raise "OutOfMemory Exception" due to GC issue. (We cannot control GC. But, this function is called very frequently and memory is allocated here. So, at some moment, if memory is not collected for a while, memory shortage can be occurred.)

* Using ViewTreeObserver.
We can know the moment when something is changed on screen view by using listeners of ViewTreeObserver - ex. orientation is changed, input method is shown and so on. Especially, OnGlobalLayoutListener is very useful. How about try using this?

+ Recent posts