Android Compass Reading Different Values On Different Phones? - android

Hello :) I am working on an application that uses the compass and location to draw an arrow at the direction of a location. My problem is when I run my code on the emulator, all the arrows point the correct directions, and when I change the orientation of the emulator to landscape, all the arrows are still correct. But when I run the same application on my Nexus One, the arrows are all correct when the phone is vertical, but when it turns to landscape all of the arrow are off by 90 degrees. It keeps the "top" of the phone as the reference to North. Thus you must correct the compass for the orientation of the phone. Does this happen on all real phones and the emulator is the different one? Or is this just the Nexus One? Thanks :)

From my understanding the current way the compass works it is supposed to always use the "top" of the phone or "default orientation" for the correct reading. This could have been different on earlier versions of android. It is said it is then up to developers to compensate for the screen orientation to represent the true north with orientation changes. Same goes for the accelerometer the axis stay based off of default screen orientation (so for most phones portrait, but tablets most would be landscape).
I hate to refer you to the sdk but this link first paragraph explains:
http://developer.android.com/reference/android/hardware/SensorEvent.html

Related

Getting the natural orientation of a device in CN1

Is there a method to check the natural orientation of a device's screen in Codename One? Meaning, the default orientation regardless of the device's current rotation or current orientation. (e.g. the result should be on a galaxy tab: landscape, on a galaxy phone: portrait)
Note: Comparing getDisplayWidth/getDisplayHeight is not expedient!
I don't think there is a native API for getting the natural device orientation in any OS. Regardless, iOS only allows you to lock device orientation properly with a build hint so that wouldn't be very useful.

Android Change Touch Screen Orientation ONLY

I am trying to create a custom device with Android and I have the device working well with at this point (looks good visually & with touch). The issue I am having is that the touchscreen does not always agree with the screen orientation. Here is the problem:
The device is set up as a tablet, and will be affixed to a table. But I want to make one version that can be used as a left-hand unit (with a small control section on the left) or a right-hand unit and have the splashscreen change with the unit orientation. My LCD allows me to flip it 180 degrees using a switch, and I can read in that signal on my processor. The problem is that when I flip the screen with the switch, the touch sensor does not come with. Where would I change this configuration? I have access to the AOSP source code, and can build custom ROMS, so that is not an issue.
Now you may also respond that I could use the accellerometer, but the issue with that is that I would see a couple of seconds of the screen being upside-down, and then the reorientation. I need it to boot up as flawlessly in the correct orientation as possible.
What I need: A place in the source code or a setting that I can change in Android that would let me change the touch screen orientation without changing the screen orientation.
Thank you for your help!

Do any Android devices have square screens?

I'm writing a game for Android and am laying out the playing screen myself, handling both vertical and horizontal orientations, and haven't done anything if the width and height are the same.
Does anybody know of at least one Android device that has a perfectly square screen resolution?
The MotoACTV is 220x176 (not square but close), the WIMM One is 160x160 (square).
The MotoACTV has been rooted, but the default device runs a customized Android. It's a pretty cool device, though. The WIMM is slick and runs a more-standard Android.
None the I'm aware of. Every device I'm familiar with has a distinctive "portrait" vs "landscape" mode.
It would probably be wise to make sure your code can always gracefully handle portrait vs landscape - even if you ever happen to run across a square device.
Conversely, if you want a square - just "crop" the image appropriately. The cropping, of course, will become "zero" if you ever encounter this hypothetical "square screen". :)
This is a rather late answer to this question, but things have changed somewhat since then, and although there are still no mainstream Android devices with square screens, there are 3 square BlackBerry devices (Q10, Q5, and Passport) that can run Android apps, and so would fall under that criteria. Interestingly, when an app is run on a square BlackBerry Passport, and the device is rotated to its side, the app also rotates, however none of the onPause(), onStop(), or onDestroy() events are called, and so the activity is not destroyed and re-created, but the current activity layout is re-used. So, in that respect, nothing happens, and you don't have to worry about saving/loading resources and such.
This behaviour is actually built-in in Android -- it will only destroy and re-create an activity, if the screen dimensions change. The API docs don't talk about this edge case, as there are no square Android devices, but you can see that the reason for destroying and re-creating the activity during orientation change is to load alternative resources specific for the new orientation. Since rotating a square device doesn't change the screen dimensions, there is no need to load alternative resources, and therefore, there's no need to destory and re-create an activity. I hope that helps.
I believe the WIMM ONE is the only square screen Android device out there. It has capacitive touch display at 160x160.
Yes, the Motorola Flipout is one.

Why does the android emulator does not rotate back?

I'm a Mac user. I just installed the Eclipse and Android SDK. However, I realised that when my emulator rotates from portrait to landscape, the view of the application does not turn back when I press fn+ctrl+11/12 again but the emulator does. This does not occur only on my app, it also occurs on the device program such as setting.
Does anyone know the reason behind it ? Please help. Thanks a lot.
You are probably running into a bug that occurs when the emulator runs certain versions of Android OS. For links, see my answer here: Android 2.3 emulator orientation changes
because each rotation is 90 degrees, the first time you tilt it, it will go sideways (90 deg). what you're experiencing when you tilt it again is that the emulator(phone) is now upside-down (180 deg). even normal android devices do not display portrait mode upside-down. tilt it two more times to go back to 0 degrees portrait.

How should the accelerometer sample android app work?

I installed the accelerometer sample app from the android SDK 2.3 om the device (Nexus s). I get several balls falling towards one side of the screen and nothing changes their position.
Is there any place in which the expected behavior of this application is described?
Does anyone here knows the expected behavior?
I suspects it exposed a problem with the hardware operation.
Thanks,
Yoav
Just ran it on a Nexus One... you hold the phone flat w.r.t. the ground. Tilting it slightly will cause the balls to fall towards the downmost edge of the screen, i.e. as if they were under the influence of real gravity.

Categories

Resources