Everything I want to do is motivated by this error, which from what I have read, I will not be able to avoid:
..
** Activity (frmmain) Pause, UserClosed = false **
** Activity (frmparteplus) Create (first time) **
GetRecordSet2: SP_GetAPPSelector @Tabla=?, @ValorBuscar=?, @Codigo=?
GetRecordSet2: exec SP_PartesGetDistancias @Lat=?, @Lon=?, @MaxKms=?, @rt_Cuantos=?, @Empleado=?
** Activity (frmparteplus) Resume **
** Activity (frmparteplus) Pause, UserClosed = false **
** Activity (frmselectorparte) Create (first time) **
** Activity (frmselectorparte) Resume **
GetRecordSet2: Select Top 100 * From CN_ParteSqlParaApp Where 1=1 And (Coalesce(Cerrado,0) = 0 or Coalesce(NoFacturable,0) = 0) And Coalesce(Parte , '') LIKE '%2023%' Order by Parte Desc
Error occurred on line: 1570 (clsConexion)
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@f98f2e2 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1312)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:405)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:148)
at android.app.Dialog.show(Dialog.java:352)
at anywheresoftware.b4a.keywords.Common.showAndTrackDialog(Common.java:591)
at anywheresoftware.b4a.keywords.Common.Msgbox2Async(Common.java:502)
at anywheresoftware.b4a.keywords.Common.MsgboxAsync(Common.java:464)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
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.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Apparently this problem occurs because the MSGBOX or MSGBOXASYNC does not detect the activity on which the message must be mounted.
Let's say it's as if it were being launched from a service, which I know you can't do.
To solve this, I was thinking of creating an instance in each Activity, because I don't see any other way to do it.
The program has many activities and before, a single module with the connection that prevents me from waiting for and what's worse, many 'The application does not respond' messages appear and more in android 13. I think that in previous versions, it hangs the program due to this.
That being said, I think I should output the module logic to a class, as Erel recommended.
But now I have this other problem with the MSGBOXASYNC (and the not recommended unsa MSGBOX).