Hi,
I'm trying to work out how to get the compass direction of the device Z axis (aka "camera axis" etc).
I am trying to emulate the logic of:
http://stackoverflow.com/questions/...n-is-different-depending-on-phone-orientation
with:
which is dying with:
at the statement:
reflect.RunStaticMethod("android.hardware.SensorManager", "remapCoordinateSystem", Array As Object(wrk1Matrix, SM_AXIS_X, SM_AXIS_Z, wrk2Matrix), Array As String("[F", "[I", "[I", "[F"))
I have used reflect.RunStaticMethod("android.hardware.SensorManager",... elsewhere without problems and I know remapCoordinateSystem is a valid method in android.hardware.SensorManager
So I'm guessing the types array Array As String("[F","[I","[I","[F") is the problem - but what? - I have run out of ideas.
Any help appreciated...
I'm trying to work out how to get the compass direction of the device Z axis (aka "camera axis" etc).
I am trying to emulate the logic of:
http://stackoverflow.com/questions/...n-is-different-depending-on-phone-orientation
with:
B4X:
Sub compass_Z(compass_X() As Float) As Float()
'http://stackoverflow.com/questions/8625804/compass-direction-is-different-depending-on-phone-orientation
Private wrk1Matrix(9), wrk2Matrix(9), result(3) As Float
wrk1Matrix = getRotationMatrixFromOrientation(compass_X)
Private SM_AXIS_X, SM_AXIS_Z As Int
SM_AXIS_X = reflect.GetStaticField("android.hardware.SensorManager", "AXIS_X")
SM_AXIS_Z = reflect.GetStaticField("android.hardware.SensorManager", "AXIS_Z")
reflect.RunStaticMethod("android.hardware.SensorManager", "remapCoordinateSystem", Array As Object(wrk1Matrix, SM_AXIS_X, SM_AXIS_Z, wrk2Matrix), Array As String("[F", "[I", "[I", "[F"))
reflect.RunStaticMethod("android.hardware.SensorManager","getOrientation", Array As Object(wrk2Matrix, result), Array As String("[F", "[F"))
Return result
End Sub
B4X:
main_compass_z (java line: 653)
java.lang.NoSuchMethodException: remapCoordinateSystem [class [F, class [I, class [I, class [F]
at java.lang.Class.getDeclaredMethod(Class.java:635)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunStaticMethod(Reflection.java:917)
at b4a.example.main._compass_z(main.java:653)
at b4a.example.main._calculatefusedorientationtask_tick(main.java:587)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
reflect.RunStaticMethod("android.hardware.SensorManager", "remapCoordinateSystem", Array As Object(wrk1Matrix, SM_AXIS_X, SM_AXIS_Z, wrk2Matrix), Array As String("[F", "[I", "[I", "[F"))
I have used reflect.RunStaticMethod("android.hardware.SensorManager",... elsewhere without problems and I know remapCoordinateSystem is a valid method in android.hardware.SensorManager
So I'm guessing the types array Array As String("[F","[I","[I","[F") is the problem - but what? - I have run out of ideas.
Any help appreciated...