Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Development

Reply
Regular Contributor
Posts: 63
Registered: ‎12-24-2010
My Device: Torch
Accepted Solution

Accelerometer orientation

[ Edited ]

Hello Playbook devs,

 

I just tried repackaging my Android games for Playbook; I've side-loaded them to the device and I have to say I am impressed - all of them work well out-of-the-box!  The only thing I had to do was provide a bigger ( 86x86 ) icon.

 

There is, however, one glitch. It's debatable if it is a bug but definately it is an incompatibility with Android tablets that's going to cause some pain.

 

My games are all accelerometer-controlled. They are also all landscape-only ( like most of the games ), so I've got a android:screenOrientation="landscape" in my manifest. 

 

Now, in Android phones and tablets, when one starts this kind of app, the screen rotates 90 degrees clockwise and the ACCELEROMETER ORIENTATION also rotates!  Whereas in Playbook, the screen rotates but the accelerometer stays in 'portrait mode' , so to speak. The effect of this:  for example in a game where one controls a car by tilting the device ( tilt forward -> speed up, tilt backward -> break, tilt left -> turn left, etc ), here tilting the Playbook forward results in turning right!

 

Now, it's not so hard to go around this, I would need to detect if the device I am running on is a Playbook and rotate the accelerometer myself, but it's one more hurdle to clear. 

 

Two questions:

 

- where I can report this

- how do I ( in my android code ) detect that the device I am running on is a Playbook

 

BlackBerry Development Advisor
Posts: 15,694
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Accelerometer orientation

Interesting find.  You can report this problem in Issue Tracker:  https://www.blackberry.com/jira/secure/Dashboard.jspa

 

I'm looking into the second question (identifying the PlayBook).

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Regular Contributor
Posts: 63
Registered: ‎12-24-2010
My Device: Torch

Re: Accelerometer orientation

[ Edited ]

Mark,

 

Thanks for your reply. Actually the Playbook accelerometer works in exactly the same way as accelerometer in your OS6 and OS7 phones: its X axis always points up the PHYSICAL screen.

 

Whereas in Android, the X axis always points up the screen as it is currently rotated.

 

Here's why the Android way is better: imagine I have a landscape-only, accel-controlled game. When I am running on a 9790 ( 480x360, physical screen in landscape ) --> means I dont have to rotate accel axis in my code. When I am running on a 9550 ( 360x480, portrait ) --> my screen gets rotated but my accel does not --> I need to compensate by rotating the axis myself.

 

To make a decision if I need to rotate axis or not, I need to know if the device I am running on has its PHYSICAL screen in portrait or landscape. And AFAIK (I've asked repeatedly in the forums ) there's NO API in OS 6 or OS 7 to tell me that ( no, getting screenWidth=480 and screenHeight=369 does NOT mean the physical screen is landscape - it can be a 9550 which the user just happens to be holding horizontally at the moment for all I know! )

 

Bottom line: such app has to have a database of all your phone models with info which one is portrait, and which landscape. Suboptimal, if you ask me. Now you're repeting this mistake in the Playbook.

BlackBerry Development Advisor
Posts: 15,694
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Accelerometer orientation

To detect if your Android application is running on a BlackBerry PlayBook you can call System.getProperty(“os.name”) and it should return “qnx”.

 

On the BlackBerry Smartphone side you can use the Display.getOrientation method to determine the screen orientation.  You do not need to build your own database of screen resolutions.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Regular Contributor
Posts: 63
Registered: ‎12-24-2010
My Device: Torch

Re: Accelerometer orientation

Thanks a lot Mark,  'System.getProperty(“os.name”)' works nicely.

 

'Display.getOrientation' : unfortunately I cannot use this because for some bizarre reason the class  'net.rim.device.api.system.Display' is protected so one needs to obtain signing keys from RIM...

Highlighted
BlackBerry Development Advisor
Posts: 15,694
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Accelerometer orientation

You'll really limit yourself if you avoid any signed Classes.

 

Code Signing keys are free.  All you need to do is fill out this form:  https://www.blackberry.com/SignedKeys/

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker