Prevent rotation on phone but not on tablet

Hi,

Do you know if its possible to prevent rotation on phone but not on Tablet. Our app support landscape and portrait but ideally we would like to only support portrait on phone and both on tablet.

Any solutions for that ?

thank you

Nick

Hello, I think what you need is device detection for this problem…

https://coronalabs.com/blog/2012/12/11/device-detection-on-steroids/

Good Luck!

Unfortunately this does not help. What I am looking for (without creating 2 sets of app) is really to prevent the OS to perform the rotation but only on phone.

Well see… On apple devices with would be easy but on android im not sure how… Never encountered this… If i figure something out ill post back!

You have two options:

  1. Don’t do a Universal build. Do a for iPad and for iPhone versions.

  2. Manage your own rotations.  The device detection blog post should give you code to determine if your on an iPhone or iPad. Then watch for orientation events and if you’re an iPad, rotate your canvas 90 degrees and re-layout things. If you’re on the iPhone, ignore the rotation event.

Rob

But what about for Android? Cause there’s thousands of types of screens and stuff out there…

Android is tougher because you can’t just use resolution or device name to determine if its a phone, phablet or tablet.  You can get information about the screen that allows you to get an idea of the size in inches (though it’s not 100% reliable, not all Android devices report things correctly).  Then once you have some idea if your on a tablet or phone, then you can use the same thing for watching for orientation events and rotate.

Rob

Thanks guys for the information, deeply appreciated. We will try this and see how it goes.

Rob, you wrote: “If you’re on the iPhone, ignore the rotation event.”

I’m assuming you meant resize event (Corona API docs say the resize event is preferred over rotation). If that’s what you meant, if you ignore the rotation event on an iPhone, doesn’t the canvas get re-laid out anyway? So your content would no longer fill the whole screen…

You have to be responsible to re-layout your app.

Hello, I think what you need is device detection for this problem…

https://coronalabs.com/blog/2012/12/11/device-detection-on-steroids/

Good Luck!

Unfortunately this does not help. What I am looking for (without creating 2 sets of app) is really to prevent the OS to perform the rotation but only on phone.

Well see… On apple devices with would be easy but on android im not sure how… Never encountered this… If i figure something out ill post back!

You have two options:

  1. Don’t do a Universal build. Do a for iPad and for iPhone versions.

  2. Manage your own rotations.  The device detection blog post should give you code to determine if your on an iPhone or iPad. Then watch for orientation events and if you’re an iPad, rotate your canvas 90 degrees and re-layout things. If you’re on the iPhone, ignore the rotation event.

Rob

But what about for Android? Cause there’s thousands of types of screens and stuff out there…

Android is tougher because you can’t just use resolution or device name to determine if its a phone, phablet or tablet.  You can get information about the screen that allows you to get an idea of the size in inches (though it’s not 100% reliable, not all Android devices report things correctly).  Then once you have some idea if your on a tablet or phone, then you can use the same thing for watching for orientation events and rotate.

Rob

Thanks guys for the information, deeply appreciated. We will try this and see how it goes.

Rob, you wrote: “If you’re on the iPhone, ignore the rotation event.”

I’m assuming you meant resize event (Corona API docs say the resize event is preferred over rotation). If that’s what you meant, if you ignore the rotation event on an iPhone, doesn’t the canvas get re-laid out anyway? So your content would no longer fill the whole screen…

You have to be responsible to re-layout your app.