What is the default behaviour for device orientation when switching between apps?

I think there is probably a technical dependency involved, but I will ask the question from a user experience perspective.

Many mobile devices run apps that have a default orientation (i.e. landscape or portrait), and depending on the way the person is holding the device the app might also be displayed in the 'up' or 'down' position in landscape view (this is not as much of an issue in portrait view as there is usually an orientation that is accepted to be correct.

I have noticed that when multiple apps are running on a mobile device, sometimes you can experience situations where you are holding the device in one orientation in landscape view, and then when you close that app or switch to another one you have to rotate the device so that it is in the right orientation.

So there are a number of factors at play in determining the orientation of the display:

  • General settings on the hardware device (e.g. allow auto-rotate)
  • General settings on the software application (e.g. allow auto-rotate)
  • The starting position in which the person is holding the device

I assume that from a user's perspective the display should always be with respect to how the person is holding the device, but given hardware and software configurations this may not always be the case.

Hence, is there some standard or guideline in managing the orientation of the device, especially when the user is switching between different apps to allow an optimal user experience?