#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private logs As StringBuilder
Private logcat As LogCat
Private Timer1 As Timer
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
logs.Initialize
#if RELEASE
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
#end if
Timer1.Initialize("timer1", 1000)
Timer1.Enabled = True
End Sub
Private Sub Timer1_Tick
Log($"Current time: $Time{DateTime.Now}"$)
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
Log("Trying to set 'i'...")
'this line will crash the program
Dim i As Int = "fdgdfg" 'ignore
End Sub
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
If logs.Length > 5000 Then
logs.Remove(0, logs.Length - 4000)
End If
End Sub
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
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 in As Intent
in.Initialize("android.intent.action.SENDTO", "mailto:")
in.PutExtra("android.intent.extra.EMAIL", Array As String("my email gmail "))
in.PutExtra("android.intent.extra.SUBJECT", "Some Subj")
in.PutExtra("android.intent.extra.TEXT", logs)
StartActivity(in)
Log("SendEmail " & LastException)
Return True
End Sub