Android Question using logcat event

ebalvis

Member
Licensed User
Longtime User
I'm trying to use LogCat in Phone Library to read the log of my app to send remotely, I have reviewed all the posts on the forum, and can not find the solution.
I understand logcat events being executed in a separate thread, and that the event can not access objects of main thread.
I tried with a very simple example:
B4X:
Sub Process_Globals
DimLoggerAsLogCat
DimArgs(1) AsString
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime AsBoolean)
  Logger.LogCatStart(Args,"MyLogCatName")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed AsBoolean)
  Logger.LogCatStop()
End Sub

Sub MyLogCatName_LogCatData(Buffer() AsByte, Length AsInt)
Dim data AsString
    data = BytesToString(Buffer,0,Length,"UTF-8")
End Sub
and the following error when calling the event, without access to any host variable thread.
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

How I can do to avoid this error?
 
Top