Android Question Clearing the toastmessageshow queue

John Sturt

Active Member
Licensed User
Longtime User
Hello
My app sends a lot of toastmessageshow commands
by the time some are displayed the app has moved onto a new phase.
Is there a way of clearing the queue?

Many Thanks
John
 

DonManfred

Expert
Licensed User
Longtime User
AFAIK no

Maybe you should creape a Label on top or Botton and use this label as a kind of "Statusbar" instead of using a Toastmessage...
You also can use the FloatingWindows class from Informatix to create a floating window wich shows your own Message in the floating window instead of a toastmessage...

You have the advantage here that you can control the position AND Layout of your "Toastmessage"

At the point you want to stop you simply hide the floating widow. and if you show a new one you set the new message and show the window again...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've used this code in B4A-Bridge to limit the number of messages:
B4X:
Sub ShowToastMessage(s As String)
   Log(s)
   If LastToastMessageShown + 5 * DateTime.TicksPerSecond > DateTime.Now Then
     Return
   Else
     LastToastMessageShown = DateTime.Now
     ToastMessageShow(s, True)
   End If
End Sub
This is useful in cases where multiple error messages may appear one after another.
LastToastMessageShown is a global variable (Long). You should call this method instead of ToastMessageShow.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…