Android Question Application_Error

Dey

Active Member
Licensed User
Longtime User
Hello to all
how to properly close the app with many Activity after handling properly the error?
activity_resume returns to where it happened error
I would completely close the app and make it start from starter
Thank you

B4X:
Dim jo As JavaObject

    Dim l As Long = 500
    jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l))
    logcat.LogCatStop
    logs.Append(StackTrace)
    Dim email As Email
    email.To.Add(emailAddress)
    'Rileggo dati per cliente nome
    DB_Type.Read_dati
    email.Subject = "BAR TABLET Program crashed " & "AZIENDA NOME " & DB_Type.dati.C020_nsede 'da mettere qua....
    email.Body = logs
    StartActivity(email.GetIntent)
    Return True
 

Dey

Active Member
Licensed User
Longtime User
Does the app continue to run after this code? It should close as you are returning True.
It is true,
after sending the email Lapp tries to continue after latching error badly
you can start it again as a starter?
thank you
 
Upvote 0

Dey

Active Member
Licensed User
Longtime User
Can you post the logs?
vista_gestione_menu_activity_exit (java line: 564)
java.lang.NumberFormatException: Invalid double: "GENERATE ERROR on purpose"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.initialParse(StringToReal.java:94)
at java.lang.StringToReal.parseDouble(StringToReal.java:282)
at java.lang.Double.parseDouble(Double.java:301)
at BAR.Orders.vista_gestione_menu._activity_exit(vista_gestione_menu.java:564)
at BAR.Orders.vista_gestione_menu._activity_keypress(vista_gestione_menu.java:580)
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 BAR.Orders.vista_gestione_menu$HandleKeyDelayed.runDirectly(vista_gestione_menu.java:228)
at BAR.Orders.vista_gestione_menu$HandleKeyDelayed.run(vista_gestione_menu.java:225)
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:6939)
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:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
** Service (starter) Create **
** Service (starter) Start **
** Activity (vista_comanda) Create, isFirst = true **
** Activity (vista_comanda) Resume **
Vista_Comanda.Activity_Resume ShouldCloseAll=false
Comanda.Activity_Resume
 
Upvote 0

Dey

Active Member
Licensed User
Longtime User
I'm creating specially a mistake to see the operation
Gmail starts with error log
when I go to Gmail again from activity call with CallSubDelayed
Mass function before generating error
What I would like to make is that the app ends
 
Upvote 0

Dey

Active Member
Licensed User
Longtime User
Try to call StopService(Me) followed by ExitApplication.

If it doesn't work then please upload a small project that demonstrates it.

Hello Erel
I'm sorry for the delay
attaching small project starting from your example, where you see that going from View 2 View 1 in-law an error and the app will not close

you think you can solve it?
I have a lot of activity that do not close in order to be more responsive
Thank you
 

Attachments

  • Test.zip
    9.3 KB · Views: 366
Upvote 0

Dey

Active Member
Licensed User
Longtime User
Not sure that I understand. Calling ExitApplication should cause the app to close after it sends the share intent.
Excuse me Erel
you can try this
It does not close the app
Sorry for the bad English translated with google translator
 

Attachments

  • Test.zip
    10.8 KB · Views: 371
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I see the problem.

I've tried various combinations. This code works properly here:
B4X:
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   'wait for 500ms to allow the logs to be updated.
   Dim jo As JavaObject
   Dim l As Long = 500
   jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l))
   logcat.LogCatStop
   logs.Append(StackTrace)
   Dim email As Email
   email.To.Add(emailAddress)
   email.Subject = "Program crashed"
   email.Body = logs
   Dim in As Intent = email.GetIntent
   in.Flags = Bit.Or(0x10000000, 0x00008000)
   StartActivity(in)
   Return True
End Sub
It shows the email app and closes the current one.
 
Upvote 0

Dey

Active Member
Licensed User
Longtime User
I see the problem.

I've tried various combinations. This code works properly here:
B4X:
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   'wait for 500ms to allow the logs to be updated.
   Dim jo As JavaObject
   Dim l As Long = 500
   jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l))
   logcat.LogCatStop
   logs.Append(StackTrace)
   Dim email As Email
   email.To.Add(emailAddress)
   email.Subject = "Program crashed"
   email.Body = logs
   Dim in As Intent = email.GetIntent
   in.Flags = Bit.Or(0x10000000, 0x00008000)
   StartActivity(in)
   Return True
End Sub
It shows the email app and closes the current one.
Hello
it does not work yet
clicking the button View 3 Activty_2 call with CallSubDelayed and after error-law, it does the error handling and app boots but Activity_2, FirstTime is False ...
I solved this way I do not know if it is correct?
I enclose Test
Thank you again for what you have created B4X
Best regards
 

Attachments

  • Test.zip
    11.4 KB · Views: 373
Upvote 0
Top