Android Question NumberFormat Exception but there is no number involved?

Didier9

Well-Known Member
Licensed User
Longtime User
This line of code:
B4X:
Dim i as Int
i = Msgbox2Async( "Do you want to save your changes?", Starter.AppName, "", "Save As", "Do Not Save", Null, False )
causes that:
B4X:
Error occurred on line: 492 (Script)
java.lang.NumberFormatException: For input string: "android.app.AlertDialog@e7cb3ca"
    at jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
    at jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:662)
    at anywheresoftware.b4a.debug.RDebugUtils.numberCast(RDebugUtils.java:67)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:205)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:8812)
    at android.widget.TextView.performClick(TextView.java:18678)
    at android.view.View.performClickInternal(View.java:8789)
    at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
    at android.view.View$PerformClick.run(View.java:33811)
    at android.os.Handler.handleCallback(Handler.java:1070)
    at android.os.Handler.dispatchMessage(Handler.java:125)
    at android.os.Looper.dispatchMessage(Looper.java:358)
    at android.os.Looper.loopOnce(Looper.java:288)
    at android.os.Looper.loop(Looper.java:392)
    at android.app.ActivityThread.main(ActivityThread.java:10346)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:638)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:972)

Line 492 is the MsgBox2Async() line

This is the app running on a hardened Samsung tablet. It is apparently not fully running...

As usual, any help appreciated.
 

knutf

Active Member
Licensed User
Longtime User
The proper way to call Msgbox2Async is shown in the contextual help:

1783374686103.png



B4X:
Dim sf As Object = xui.Msgbox2Async("Delete file?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
    Log("Deleted!!!")
End If

You should also note that to hide the Negative button you should pass an empty string. An empty string is "".
If you do not want an icon you pass Null for the icon
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
The proper way to call Msgbox2Async is shown in the contextual help:

View attachment 172241


B4X:
Dim sf As Object = xui.Msgbox2Async("Delete file?", "Title", "Yes", "Cancel", "No", Null)
Wait For (sf) Msgbox_Result (Result As Int)
If Result = xui.DialogResponse_Positive Then
    Log("Deleted!!!")
End If

You should also note that to hide the Negative button you should pass an empty string. An empty string is "".
If you do not want an icon you pass Null for the icon
Thank you, I did see that my Msgbox2Async syntax was not correct, but the example I found was also incorrect, yet was not causing a compilation error, just th code did not do anything and I was in the process of pulling whatever hair I have left...
It is now working, thank you!

PS: I need to use the Contextal box more :(
 
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime User
You should also note that to hide the Negative button you should pass an empty string. An empty string is "".
If you do not want an icon you pass Null for the icon
This at least has not changed, and I was already taking advantage of that.
Thank you!
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
B4X:
Error occurred on line: 492 (Script)

Line 492 is the MsgBox2Async() line

As you writed, the issue is not on compiler but in running time, so I think that line 492 is not refered to your source code but on java source.
You are seeing MsgBox2Async() line, but IMHO it is not the issue line
 
Upvote 0
Top