Android Tutorial Orientation and accelerometer

Mitesh_Shah

Member
Licensed User
Longtime User
HI i am new in b4a. i need some help to put ACCELEROMETER data (X,Y,Z) into some text box and SeekBar

thanks
 

dossa

New Member
Hello.
i need to give only accelerometer data(z) in variable. Can you help me?
Sorry for my english.
thanks
 

JordiCP

Expert
Licensed User
Longtime User
Hi all,

I want my app to decide when to be drawn in portrait or landscape mode, or reverse ones. Based on the X,Y sensors, it seems to be easy to know when it has rotated.

For instance, in a phone I get theses values (aprox)

portrait: X=0 Y=9.8
lanscape: X=9.8 Y=0 (rotating 90º left from portrait)

when running on a tablet, I have,

landscape: X=0 Y=9.8
portrait: X=9.8 Y=0

So sensors info is not enough for me to decide when to draw in landscape or portrait, since X,Y assignments seem to be related to the device default orientation. How can I decide how these values are related to the actual screen orientation?

(One possible approach would be trying to "guess" default screen orientation based on device type and screen size, but I am sure this will not work always.)

----------EDIT------------------------
Have just found LibDisplay tutorial from joseluis

http://www.b4x.com/android/forum/threads/libdisplay-module.14111/#post79879

So I assume that accelerometer sensor information is related to the default screen.

Thanks.
 
Last edited:

JordiCP

Expert
Licensed User
Longtime User
Why don't you let Android take care of that?

You can set the #SupportedOrientations value to fullSensor.

Thank you for pointing this, Erel

There are two reasons for doing it this way

  1. My app uses the camera and only want the device to rotate under certain situations. For instance, not rotate accidentally when taking the photo, and let the user rotate freely when editing it
  2. In some devices, I still have a problem each time I rotate, memory gets lower till it crashes as stated here. So I want the user to start the app in the orientation he chooses, but blocking rotation afterwards.

I would prefer only to control it only for reason 1, but the second is also there
 

Scooter Willis

Member
Licensed User
Longtime User

I have the same repeated output of true problem when beginning to listen to sensor value for barometric pressure. Using v3.0 with 2.2 phone library.
 

Ashley

Member
Licensed User
Longtime User
Hi Erel, I'm trying to get the exact direction in degrees the phone is facing. The position variables (x,y,z) seems to give errors in some directions. Is there any code that combines the relevant sensors to get the AHRS?.
Thanks
Ashley
 

apty

Active Member
Licensed User
Longtime User
how can i run a service that displays x,y,z values of the sensor (accelerometer only)? i.e instead of activity module, i make it service module
 

flightnet

Member
Licensed User
Longtime User
Hey,
I have an additional question, how can I find the g. If I propebly swing the phone so that it Shows me how meny g are given in this Moment.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…