开发者

What is the difference between Display.getRotation() and Display.getOrientation() apart from the fact that Display.getOrientation() is deprecated?

What is the difference between Display.getRotation() and Display.getOrientation() apart from the fact that it Display.getOrientation() is deprecated?

Do both return an int equal to one of开发者_如何学编程 Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270?


getRotation() just calls the deprecated method getOrientation(), check the source code of class Display. So it seems to have been deprecated merely for a better name.


The two methods are exactly the same, getRotation() simply calls getOrientation(). For this reason, I am using getOrientation() in my app in order to add support for lower Android levels. I see no reason to limit my ability to distribute my app simply so it can have a different method name. Thus, I completely agree with jap1968.


The answer just tells the same as the Android documentation. Many people has devices whose manufacturers do not update. I find nonsense to make an application just for users having modern devices, when the main functionality of the application does not require anything not present even (in my case) in API v1.


From Android Developer Site here:

public int getOrientation ()

Since: API Level 1 This method is deprecated. use getRotation()

Returns

orientation of this display.


public int getRotation ()

Since: API Level 8 Returns the rotation of the screen from its "natural" orientation. The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90, Surface.ROTATION_180, or Surface.ROTATION_270. For example, if a device has a naturally tall screen, and the user has turned it on its side to go into a landscape orientation, the value returned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 depending on the direction it was turned. The angle is the rotation of the drawn graphics on the screen, which is the opposite direction of the physical rotation of the device. For example, if the device is rotated 90 degrees counter-clockwise, to compensate rendering will be rotated by 90 degrees clockwise and thus the returned value here will be Surface.ROTATION_90.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜