Question

How to detect an orientation change in Corona SDK on Android for an Landscape Only app?

I note that the following do not work:

  • using the orientation event won't work - this is noting an orientation event is not produced when switching between landscapeLeft to landscapeRight or vice-versa (i.e. portrait not supported in the app)

  • using the "resize" event doesn't work - it only occurs for apps that support both portrait and landscape orientations

MAIN QUESTION THEREFORE: How to detect an orientation change in Corona SDK on Android for an Landscape Only app?

UPDATE: Actually some concerning is that I've just confirmed that on Android (on my new Nexus 7) that "system.orientation" is NOT changes when I tip the device upside down. That is it stay on "landscapeRight". So would this be a Corona bug? Only fix is going to be not allowing users to be able to tip/use the game upside down then no? (i.e. in landscapeLeft)

Was it helpful?

Solution

Corona won't distinguish between landscapeLeft and landscapeRight if your app only supports landscape mode. The Docs for Project Build Settings (http://docs.coronalabs.com/guide/distribution/buildSettings/index.html) state that:

4.In Android 2.2, if you build a landscape-only app by supporting landscapeRight and landscapeLeft, it will never display in the landscapeLeft mode. Likewise, if you build a portrait-only app by supporting portrait and portraitUpsideDown, it will never appear as portraitUpsideDown. This is an Android 2.2 limitation.

I've created a small project and can confirm that on my Nexus4 with Android 4.3, "orientation" event too doesn't get called (although it works in Simulator).

To answer your questions then: you can't detect orientation change for landscape only app. It doesn't seem to be Corona bug, rather Android limitation.

OTHER TIPS

Currently on Android devices, orientation events are only generated when auto-rotation is enabled in the build.settings file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top