Android Question Answered: LogCatStart - event not firing

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Phone.LogCat is very short on examples. I am trying to capture 5,000 characters in a round robin. In this way, at any moment I can capture recent LOGCAT from devices running the software in the field.

From a module named Globals:

B4X:
Sub Process_Globals
          ...
    Private logcat As LogCat
    Private logString As StringBuilder
End Sub

Public Sub Init
             ...
    logString.Initialize
    logcat.LogCatStart(Array As String(),"logcat")       
End Sub

Sub logcat_LogCatData(Buffer() As Byte, Length As Int)
    Dim data As String
    data = BytesToString(Buffer,0,Length,"UTF-8")
    logString.Append(data)
    If logString.Length > 5000 Then
        logString.Remove(0,logString.Length-5000)
    End If
End Sub

I have added this with the Manifest Editor:
B4X:
AddPermission(android.permission.READ_LOGS)

my logcat_LogCatData routine is apparently never called.

I have experimented with Args...
"-v long"
"-v"
neither affect non-execution of the event.
 

Lee Gillie CCP

Active Member
Licensed User
Longtime User
It fires fine from the main activity with similar code. Can not seem to figure out how to hook the handler from a module. But I suspect I won't get event delivery when other activities are stacked over the main activity? Is there a way to keep this constantly and continuously monitoring? The point is to have ALL recent LOGCAT to report in a crash dump in the event of an error.
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
Ok, adding a service module. I don't see how to get this run down, so will post a new question.
 
Upvote 0
Top