What is the difference between onAttachedToWindow and onStart

I sometimes see people using the Activity.onAttachedToWindow method, but personally, I never used it. When reading the documentation, it seems to me that it will be almost the same as onStart() .

One thing I assume: onAttachedToWindow is called before onCreate() onStop is called after.

Am I correct with this assumption? How on behalf of and who do you use?

+4
source share
1 answer

onAttachedToWindow :

This is called when the view is attached to the window. At this stage it has a surface and will start drawing. Note that this function is guaranteed to be called before onDraw (android.graphics.Canvas), however, it can be called at any time before the first onDraw - including before or after onMeasure (int, int).

The life cycle of an activity is described here .

I found that " starting a new activity (Theme.Dialog style) from onAttachedToWindow () significantly improves the response time when comparing it with onCreate () "

+7
source

Source: https://habr.com/ru/post/1388923/


All Articles