Get direction and angle

arturataide

Member
Licensed User
Longtime User
How can i get the direction and the angle of my phone using the accelerometer and the magnetic sensor..
I want the horizontal direction and the angle between the floor and the mobile phone like -> _| = 90º
thank you in advance
Cumps
Artur Ataíde
 

Jost aus Soest

Active Member
Licensed User
Longtime User
Use statements like the following:
B4X:
'Sub Process_Globals:
Dim OrientationSensor As PhoneSensors

'Sub Activity_Create:
If FirstTime Then _
OrientationSensor.Initialize2(OrientationSensor.TYPE_ORIENTATION, 2)

'Sub Activity_Resume:
OrientationSensor.StartListening("OrientationSensor")

'Sub Activity_Pause:
OrientationSensor.StopListening

'Sub OrientationSensor_SensorChanged(Values() As Float):
Dim NewOrientation As Int
NewOrientation = Round(Values(0))
'...
 
Upvote 0

arturataide

Member
Licensed User
Longtime User
Use statements like the following:
B4X:
'Sub Process_Globals:
Dim OrientationSensor As PhoneSensors

'Sub Activity_Create:
If FirstTime Then _
OrientationSensor.Initialize2(OrientationSensor.TYPE_ORIENTATION, 2)

'Sub Activity_Resume:
OrientationSensor.StartListening("OrientationSensor")

'Sub Activity_Pause:
OrientationSensor.StopListening

'Sub OrientationSensor_SensorChanged(Values() As Float):
Dim NewOrientation As Int
NewOrientation = Round(Values(0))
'...

Thank you :D
i'll try
 
Upvote 0
Top