Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is orientation change handled in the message queue?

Tags:

android

Is it an atomic operation?

I mean is it possible that anything else gets executed on the main thread during an orientation change?

For example, let's say the flow on the main thread is something like this:

someOperation -> orientationChangeStart -> someOtherOperation -> orientationChangeEnd

Is this possible?

Can someOtherOperation get executed on the UI thread while an orientation change is in progress?

Thanks in advance.

like image 716
justanoob Avatar asked Oct 04 '16 11:10

justanoob


1 Answers

Yes, it is atomic operation.

in pseudo it looks like:

void setNewOrientation(int state) {
    currentState = state;
    runOrientationChangedEvent();
}

And then usually Activity is re-created. Only re-creating of Activity adds to the message queue, so it is possible to see if change device orientation fast enough.

You cannot get start and end of this process, because it just changes a few int variables which can tell you about current orientation like orientation:

getActivity().getResources().getConfiguration().orientation

or rotation

getWindowManager().getDefaultDisplay().getRotation();

So you can get event only after orientation is changed.

like image 66
Andrey Danilov Avatar answered Oct 13 '22 20:10

Andrey Danilov