To close the toast message, only when new toast is fired or else it should stick to old toast message.
closed as off-topic by Sebastian Kessel, David Reed♦, battery.cord, glls, Oleksandr Berehovskyi Jul 4 '18 at 8:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: SSCCE.org" – Sebastian Kessel, David Reed, battery.cord, glls, Oleksandr Berehovskyi
You can't. There's no API available for a developer to alter a toast once it has been dispatched, including closing the toast or altering its behavior. You have three basic options here: show the toast until a duration has elapsed, show the toast until the user dismisses it, or show the toast until the duration has elapsed or the user dismisses it, whichever occurs first. If you need a more robust toasting mechanism, you'll have to write your own custom component, instead.