Android Question Numpad Hint

denik

Member
Licensed User
Longtime User
I need change hint programmatically in class NumPad
[customview] - Numpad
For this purpose, sub was added to the class
B4X:
Public Sub setHint(s As String)
    If flEditText1.IsInitialized = False Then
        CallSubDelayed2(Me, "setHint", s)
        Return
    End If
    flEditText1.Hint = s
End Sub

Numpad2.Hint = "MyHint" - the only addition in example from Erel work in Debug and Release but in Release (obfuscated) error
B4X:
java.lang.Exception: Sub sethint was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:185)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6272)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
--------- beginning of crash
real devices, Android 4.4 & 7.0, b4A ver 6.80
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
If you are calling any sub using CallSub or CallSubDelayed or any thing else that uses a string name, the SubName should include an underscore if you are going to use Obsfuscation. The underscore stops the sub name being obsfuscated so that it can be found.

If you change the name to something like set_Hint, then is should work.

Although I'm not quite sure of the logic of the sub, I'll assume it is an example.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you are calling any sub using CallSub or CallSubDelayed or any thing else that uses a string name, the SubName should include an underscore if you are going to use Obsfuscation.
Note that in most cases it should work without an underscore. The compiler does try to find CallSub usages. Maybe it fails here because it is a property.

An underscore is the best solution. As a test you can try it with SetHint instead of setHint.
 
Upvote 0

denik

Member
Licensed User
Longtime User
I can't rename Sub setHint (eg insert underscore), because I have no access to it.

With
CallSubDelayed2(Me, "setHint", s) and
CallSubDelayed2(Me, "SetHint", s)
I have the same error
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
CallSubDelayed2(Me, "setHint", s) and
CallSubDelayed2(Me, "SetHint", s)
I have the same error
you need to use the underscore here too....
 
Upvote 0
Top