About orientation event

I use the event “orientation” and I read in the doc that on android only the types “portrait” and “landscapeRight” are detected. But why on my mobile I can dectect “landscapeLeft” and “portraitUpsideDown” too ? Is it because of android versions? [import]uid: 107239 topic_id: 30243 reply_id: 330243[/import]

Have a look at the “Note” section in the link below. It should help explain this.
http://developer.coronalabs.com/content/configuring-projects#Orientation_Support_iOS
[import]uid: 32256 topic_id: 30243 reply_id: 121386[/import]

Thanks for the answer.
In my case I don’t want to rotate the screen, I just want to detect the orientation of the device :

Runtime:addEventListener(“orientation”,onOrientation)

And without specifying nothing in the build.settings file, it detects ALL the orientations, not only “portrait” and “landscapeRight”. I wanted to know if it works on 2.2 or above only. [import]uid: 107239 topic_id: 30243 reply_id: 121394[/import]

If your app has a fixed orientation, that is your “build.settings” only supports one kind of orientation, then your app will detect all 4 orientations (portrait, portraitUpsideDown, landscapeRight, landscapeLeft) on all Android operating system versions, including Android 2.2. This is possible because Corona enables a sensor in the background in this case to track the device’s orientation.

You can find a good example of this in sample project “Graphics\Fishies” which is included in the Corona SDK. It is a fixed orientation app that listens for orientation events and handles orientation changes itself.

Now, if your app’s “build.settings” file is set up for multiple orientation (ie: portrait and landscape), then the orientation events come from the operating system instead. In this case, Android phones typically only provide 3 orientation events such as portrait, landscapeRight, and landscapeLeft… even on Android 2.2. Android tablets usually provide all 4 orientations.
A good example of this behavior can be seen in sample app “Interface\NativeDisplayObjects” which is included with the Corona SDK.

I hope this helps! [import]uid: 32256 topic_id: 30243 reply_id: 121567[/import]

Thank you very much for all the details, it totally what I wanted to know :wink: [import]uid: 107239 topic_id: 30243 reply_id: 121618[/import]

Have a look at the “Note” section in the link below. It should help explain this.
http://developer.coronalabs.com/content/configuring-projects#Orientation_Support_iOS
[import]uid: 32256 topic_id: 30243 reply_id: 121386[/import]

Thanks for the answer.
In my case I don’t want to rotate the screen, I just want to detect the orientation of the device :

Runtime:addEventListener(“orientation”,onOrientation)

And without specifying nothing in the build.settings file, it detects ALL the orientations, not only “portrait” and “landscapeRight”. I wanted to know if it works on 2.2 or above only. [import]uid: 107239 topic_id: 30243 reply_id: 121394[/import]

If your app has a fixed orientation, that is your “build.settings” only supports one kind of orientation, then your app will detect all 4 orientations (portrait, portraitUpsideDown, landscapeRight, landscapeLeft) on all Android operating system versions, including Android 2.2. This is possible because Corona enables a sensor in the background in this case to track the device’s orientation.

You can find a good example of this in sample project “Graphics\Fishies” which is included in the Corona SDK. It is a fixed orientation app that listens for orientation events and handles orientation changes itself.

Now, if your app’s “build.settings” file is set up for multiple orientation (ie: portrait and landscape), then the orientation events come from the operating system instead. In this case, Android phones typically only provide 3 orientation events such as portrait, landscapeRight, and landscapeLeft… even on Android 2.2. Android tablets usually provide all 4 orientations.
A good example of this behavior can be seen in sample app “Interface\NativeDisplayObjects” which is included with the Corona SDK.

I hope this helps! [import]uid: 32256 topic_id: 30243 reply_id: 121567[/import]

Thank you very much for all the details, it totally what I wanted to know :wink: [import]uid: 107239 topic_id: 30243 reply_id: 121618[/import]

@Joshua,
I recently resubmitted upgrades for 3 apps on Amazon.
2 passed all testing for all Kindles.
1 failed on kindle fire HD; from their message : “has failed compatibility testing on Kindle Fire HD for a Graphics issue. When launching the app, the screen orientation is upside down. Please update this app and resubmit.”

All 3 apps:
* support only landscape left and right
* have the same build.settings and config.lua files (except for the version part) for android
* use rotationfix.lua from Pixel EnVision

have you seen this failure before?
any idea what could be causing the failure in only one of the apps?
thanks.
[import]uid: 32063 topic_id: 30243 reply_id: 131011[/import]

@Joshua,
I recently resubmitted upgrades for 3 apps on Amazon.
2 passed all testing for all Kindles.
1 failed on kindle fire HD; from their message : “has failed compatibility testing on Kindle Fire HD for a Graphics issue. When launching the app, the screen orientation is upside down. Please update this app and resubmit.”

All 3 apps:
* support only landscape left and right
* have the same build.settings and config.lua files (except for the version part) for android
* use rotationfix.lua from Pixel EnVision

have you seen this failure before?
any idea what could be causing the failure in only one of the apps?
thanks.
[import]uid: 32063 topic_id: 30243 reply_id: 131011[/import]

Does you “build.settings” file have both “landscapeRight” and “landscapeLeft” listed in your supported orientation list?
If you could post your “build.settings” file contents here, then I can do a quick spot check for your.
[import]uid: 32256 topic_id: 30243 reply_id: 131122[/import]

Does you “build.settings” file have both “landscapeRight” and “landscapeLeft” listed in your supported orientation list?
If you could post your “build.settings” file contents here, then I can do a quick spot check for your.
[import]uid: 32256 topic_id: 30243 reply_id: 131122[/import]

@Joshua,
this very same app has passed Nook testing for all their devices.
let me know if you would like me to email you the apk.
build.settings:
settings =
{

orientation =
{
default = “landscapeRight”,
supported =
{
“landscapeLeft”,
“landscapeRight”,
},

},

android =
{
versionCode = “13” – for version 1.3, Kindle
},

androidPermissions =
{
“android.permission.INTERNET”,
“android.permission.WRITE_EXTERNAL_STORAGE”, --to save screenshots to photo library

},

iphone =
{

plist =
{
CFBundleIconFiles =
{
“IconFree.png” ,
“IconFree@2x.png” ,
“IconFree-72.png” ,
“IconFree-Small.png”,
“IconFree-Small@2x.png”,
“IconFree-Small-50.png”,
“iTunesArtwork”,
},

UIAppFonts =
{
“AlmagroRegular.ttf”,
“ScribbleRegular.ttf”,
},

UIPrerenderedIcon = true,

UIStatusBarHidden = true,

–UIApplicationExitsOnSuspend = true, --forces app to relaunch from start after suspend

CFBundleDisplayName = “Pickles Free”, --sets name under the icon

CFBundleVersion = “1.1”,

},

components = {“openfeint”}, --for openfeint
},
}
[import]uid: 32063 topic_id: 30243 reply_id: 131159[/import]

@Joshua,
I got more details from Amazon.
The person handling this there is Tony M.
It still doesn’t make sense that this app failed while the other 2 passed having the exact same way of handling orientation.

any suggestions?

Thank you for writing back. This is a common issue, for a device with a default orientation of portrait, both ROTATION_90 and ROTATION_270 result in a landscape orientation. The default landscape orientation for the Kindle Fire (1st Generation) and Kindle Fire (2nd Generation) is ROTATION_90. The default landscape orientation for the Kindle Fire HD tablets is ROTATION_270. More detail can be found here:
https://developer.amazon.com/sdk/fire/best-practices.html

For further reference:
Problem – Some games are rotated upside down in Landscape
Orientation handling can easily be configured in the Manifest. Use tag android:screenOrientation
However for backward compatibility it is common for games to handle this internally. Especially games
which support both landscape orientations only.

Problem step 1 - Device is turned - new accelerometer reading (–g, 0)

Problem step 2 - The game detects the accelerometer change and tries to compensate by calling
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)

Mitigation step 3 - Since the definition of landscape is different the game should actually go to reversed
landscape. There is no API to get this info so the change have to happen after the
initial call to setRequestedOrientation().
Code needed to mitigate this issue (only landscape covered here):
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
if (wm.getDefaultDisplay().getRotation() != Display.ROTATION_90) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSED_LANDSCAPE);
}
[import]uid: 32063 topic_id: 30243 reply_id: 131166[/import]

Your “build.settings” file is set up correctly.

We added “landscapeLeft” support to Android as of daily build #919. So, as long as your app is built with #919 or higher, your app will support both landscapeRight and landscapeLeft orientations on Android 2.3 or higher devices (this includes the Kindle Fire HD). You can easily prove that this works on your own Android device. If you’ve built you app with an older version, then I am certain that this is the issue.

I have never heard of the “rotationfix.lua” script that you are using. I’m pretty sure that you will not receive an orientation event when you switch between landscapeRight and landscapeLeft because the Android OS never sends the event in that case. Android will only send orientation events when switching between portrait and landscape… and vice-versa… or for fixed orientation apps (love the special rule, eh?). Android will automatically flip the screen for you (usually with animation) and will not tell the app it did it. But that said, this will happen on all Android devices; not just the Kindle Fire HD.

I’m not sure what else to advise at this point. Tony’s info about the accelerometer is definitely not an issue in Corona, because Corona already correctly handles Android devices with a natural landscape orientation.
[import]uid: 32256 topic_id: 30243 reply_id: 131182[/import]

@Joshua,

  1. we used a daily build #944

  2. rotationfix.lua is a code shared in the corona site by Pixel EnVision. It does immediate rotation without that big black animation rectangle.
    http://developer.coronalabs.com/code/proper-orientation-rotation-animation

  3. I don’t have a kindle fire HD to test on. That is the only device they say it fails on.

My other 2 apps use exactly the same code for build.settings and rotationfix.lua, were built with same corona version and passed testing on all kindles. It doesn’t make sense that this one doesn’t.
What to do?
Do you want to run the apk on your kindle fire HD? [import]uid: 32063 topic_id: 30243 reply_id: 131190[/import]

@Joshua,
this very same app has passed Nook testing for all their devices.
let me know if you would like me to email you the apk.
build.settings:
settings =
{

orientation =
{
default = “landscapeRight”,
supported =
{
“landscapeLeft”,
“landscapeRight”,
},

},

android =
{
versionCode = “13” – for version 1.3, Kindle
},

androidPermissions =
{
“android.permission.INTERNET”,
“android.permission.WRITE_EXTERNAL_STORAGE”, --to save screenshots to photo library

},

iphone =
{

plist =
{
CFBundleIconFiles =
{
“IconFree.png” ,
“IconFree@2x.png” ,
“IconFree-72.png” ,
“IconFree-Small.png”,
“IconFree-Small@2x.png”,
“IconFree-Small-50.png”,
“iTunesArtwork”,
},

UIAppFonts =
{
“AlmagroRegular.ttf”,
“ScribbleRegular.ttf”,
},

UIPrerenderedIcon = true,

UIStatusBarHidden = true,

–UIApplicationExitsOnSuspend = true, --forces app to relaunch from start after suspend

CFBundleDisplayName = “Pickles Free”, --sets name under the icon

CFBundleVersion = “1.1”,

},

components = {“openfeint”}, --for openfeint
},
}
[import]uid: 32063 topic_id: 30243 reply_id: 131159[/import]

@Joshua,
I got more details from Amazon.
The person handling this there is Tony M.
It still doesn’t make sense that this app failed while the other 2 passed having the exact same way of handling orientation.

any suggestions?

Thank you for writing back. This is a common issue, for a device with a default orientation of portrait, both ROTATION_90 and ROTATION_270 result in a landscape orientation. The default landscape orientation for the Kindle Fire (1st Generation) and Kindle Fire (2nd Generation) is ROTATION_90. The default landscape orientation for the Kindle Fire HD tablets is ROTATION_270. More detail can be found here:
https://developer.amazon.com/sdk/fire/best-practices.html

For further reference:
Problem – Some games are rotated upside down in Landscape
Orientation handling can easily be configured in the Manifest. Use tag android:screenOrientation
However for backward compatibility it is common for games to handle this internally. Especially games
which support both landscape orientations only.

Problem step 1 - Device is turned - new accelerometer reading (–g, 0)

Problem step 2 - The game detects the accelerometer change and tries to compensate by calling
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)

Mitigation step 3 - Since the definition of landscape is different the game should actually go to reversed
landscape. There is no API to get this info so the change have to happen after the
initial call to setRequestedOrientation().
Code needed to mitigate this issue (only landscape covered here):
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
if (wm.getDefaultDisplay().getRotation() != Display.ROTATION_90) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSED_LANDSCAPE);
}
[import]uid: 32063 topic_id: 30243 reply_id: 131166[/import]

Your “build.settings” file is set up correctly.

We added “landscapeLeft” support to Android as of daily build #919. So, as long as your app is built with #919 or higher, your app will support both landscapeRight and landscapeLeft orientations on Android 2.3 or higher devices (this includes the Kindle Fire HD). You can easily prove that this works on your own Android device. If you’ve built you app with an older version, then I am certain that this is the issue.

I have never heard of the “rotationfix.lua” script that you are using. I’m pretty sure that you will not receive an orientation event when you switch between landscapeRight and landscapeLeft because the Android OS never sends the event in that case. Android will only send orientation events when switching between portrait and landscape… and vice-versa… or for fixed orientation apps (love the special rule, eh?). Android will automatically flip the screen for you (usually with animation) and will not tell the app it did it. But that said, this will happen on all Android devices; not just the Kindle Fire HD.

I’m not sure what else to advise at this point. Tony’s info about the accelerometer is definitely not an issue in Corona, because Corona already correctly handles Android devices with a natural landscape orientation.
[import]uid: 32256 topic_id: 30243 reply_id: 131182[/import]