Android Question Rotate phone

ilan

Expert
Licensed User
hi, try PhoneAccelerometer for that (use the Z axis to check if phonescreen is on table...)

B4X:
Sub Process_Globals
    Dim Accelerometer As PhoneAccelerometer
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)

End Sub

Sub Activity_Resume
    Accelerometer.StartListening("Accelerometer")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    Accelerometer.StopListening
End Sub

Sub Accelerometer_AccelerometerChanged (X As Float, Y As Float, Z As Float)
    Log("Z: " & Z)
End Sub
 

Cableguy

Expert
Licensed User
you should/could also use the light sensor to check if in fact the phone is facing a table
 
Top