How does the Android coordinate system work?

The official documentation gives this example image:

enter image description here It is also stated in the documentation, that if the device moves, the coordinate system is the same. How can I imagine this? If I for example hold my phone like a compass, will the coordinate system look like this (ignore roll, pitch & azimuth)?:

enter image description here

Or is it meant that the coordinate system is relative to the environment and not to the screen like the 2 examples above, thus if the device moves, the coordinate system still is the same?