Android Question Rotate phone

dibesw

Active Member
Licensed User
Longtime User
Can I take rotate smartphone event for this case?

images2.jpg
 

ilan

Expert
Licensed User
Longtime 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
 
Upvote 0

Cableguy

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

ilan

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

will it also work if the table is made of glass? :rolleyes:
 
Upvote 0
Top