The accelerometer and gyroscope figures go mad when i run that example. The
accelerometer and gyro numbers never stop changing even though my phone is face up on the table and not moving.
I have a Galaxy S4 to test on and this example say that Orientation is not supported, but I know other apps ( Tasker ) where it works perfectly well.
Hi Antony,
I don't know this matter well, so I had a quick look at the documentation.
To access the getRotationMatrix function by the Reflection lib, you should code something like the following:
B4X:
Dim R As Reflector
Dim b As Boolean
Dim Rot(9),Inclin(9),Grav(3),GeoM(3) As Float
b=R.RunStaticMethod("android.hardware.SensorManager","getRotationMatrix",Array As Object(Rot,Inclin,Grav,GeoM),Array As String("[F","[F","[F","[F"))
If b = True Then Log("success: "&Rot(8)) Else Log("error")
Before the function call, use Erel's tutorial to get values to pass in Gravity and GeoMagnetic arrays.
I'm sure someone more knowledgeble on the subject will jump in and help you in a more precise way.
Very very helpful. Thank you so much
Can't try it right now, as I have to earn my pennies at work ;-)
As soon as I am in front of my home PC I will be trying this
please find attached a project skeleton that, in a way, does it all as the StackOverflow example.
It's more a proof on concept than a functioning app, so there's some work for you to be done.
Anyway, it seems to works well with my tablet..
Thanks for your example anthony, I am trying to call getOrientation using your example, so like this:
b2=R2.RunStaticMethod("android.hardware.SensorManager","getOrientation",Array As Object(Rot,ypr),Array As String("[F","[F")