Android Question Read string from File, AstreamsText ?

vdudukov

Member
Licensed User
Longtime User
Hi everyone.

Is it possible to read string from text file every moment, without TextReader and Timer ?
Is it possible with AsyncStreamsText class ?

Now my code looks like:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    tmr.Initialize("time",500)
    tmr.Enabled = True
    textreader1.Initialize(File.OpenInput("/dev/","ttyMT2"))
End Sub

Sub time_tick
    Dim line As String
    line = textreader1.ReadLine  
    Do While line <> Null
        Log(line)
        edittext2.Text = line
    Loop
  
End Sub

Thanks!
 

Beja

Expert
Licensed User
Longtime User
Hi, you didn't mention if the above code is working..
If it is working then case closed.. just have your criteria and compare it to the text line each time.. if match then stop the iteration and disable timer.
 
Upvote 0

vdudukov

Member
Licensed User
Longtime User
No, that is not working fine. Sometimes text from file is complete, somtimes not.
If I put timer faster, application working very slow.

Thanks Erel, Ill try.
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
you better disable the timer in the _tick event and enable it again before the end sub or you'll end up with a pile of tasks running and worst case ending up with stack overflow like errors.
 
Upvote 0
Top