Android Question JSTouchImageView and x y positions

mike1967

Active Member
Licensed User
Longtime User
Hello I have this code:
B4X:
Sub imgViewPlanimetria_OnItemClick
   
    Dim rTI As Reflector, rGD As Reflector
    rTI.Target=imgViewPlanimetria
    Dim mGD As JavaObject = rTI.GetField("mGestureDetector")
    rGD.Target=mGD
    Dim ptX As Object = rGD.GetField("mDownFocusX")
    Dim ptY As Object = rGD.GetField("mDownFocusY")
    Dim aPointObject As JavaObject = rTI.RunMethod4("transformCoordTouchToBitmap", _
            Array As Object(ptX,ptY,False), Array As String("java.lang.float", _
            "java.lang.float","java.lang.boolean"))
    Dim x, y As Float
    x = aPointObject.getfield("x")
    y = aPointObject.getfield("y")
    Log(x)
    Log(y)
   
End Sub
and i try to read x y coordinates of a zooomable images but the code return this error :

B4X:
planimetria_touchimage_onitemclick (java line: 520)
java.lang.NoSuchFieldException: No field mDownFocusX in class Landroid/view/GestureDetector; (declaration of 'android.view.GestureDetector' appears in /system/framework/framework.jar!classes2.dex)
    at java.lang.Class.getDeclaredField(Native Method)
    at anywheresoftware.b4a.agraham.reflection.Reflection.GetField(Reflection.java:316)
    at com.app.regant.planimetria._touchimage_onitemclick(planimetria.java:520)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
    at anywheresoftware.b4a.BA$1.run(BA.java:352)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
in a B4XPages

Can help me ? Thanks in advances
 

DonManfred

Expert
Licensed User
Longtime User
No field mDownFocusX in class Landroid/view/GestureDetector
there is no such field mDownFocusX in Androids Gesture Detector.


Maybe there is one in the Gesture-Detector library and you need to get the field from it instead.
There is also no such field or property in the Gesture-Detector-Library....
 
Last edited:
Upvote 0

mike1967

Active Member
Licensed User
Longtime User
The fact Is that in the samples run as standard Activity the code work,in my app none
 
Upvote 0

mike1967

Active Member
Licensed User
Longtime User
Maybe the underlying SDK has changed?
I can see the library is from 2016.

A lot has changed since then. Starting with AndroidX-SDK instead of the old and deprecated Adndroid-Support SDK. And probably other changes too.
Infact don't works thanks anyway
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…