Can unity get the native orientation of an android device?

Hi everyone. This is a follow on question from :

It seems that the source of my original problem is that android tablets, and android phones have different native orientations of the accelerometer in relation to the screen.

please see the diagram at the bottom of this page.

in short.

landscape tablets see x and y accelerometer readings differently.

they see y as up/down from a landscape position. this would be x on a phone.

How can I detect this?

I think you could do it like Tilt 2 Live, a game on iPhone which supports different orientations.

Have a “calibrate” screen where it asks the user to hold the device as he will while playing. Read the data that comes in, and set that as the neutral orientation. Maybe add a snap to certain axes or angles (like 45, 60 or 90).

I’ve had to revisit this problem.

There is a way to detect the default orientation of an android device in the sdk, and automatically adjust the accelerometer values as outlined in this blogpost on the android blog.

Now it doesn’t look like Unity allows me access to this data without writing a plugin. Surely something so simple should be implemented in the Screen class? Like Screen.defaultOrientation or Screen.autoAdjustAccellerometer?

There’s a solution courtesy of Ralph Barbagallo using Unity’s access to AndroidJavaClass - see Detecting Android Tablets and Phones in Unity3D