Search code examples
nativescripttoast

Kill the current Toast Notificatoin


Is there any option to kill/hide/cancel current Toast Notification under Android 10 + TNS?

I want to show the meaning of some words by tapping on them, but under Android 10 user needs to wait until previous Toast Notification times out until he/she can see the next one.


Solution

  • The answer is found!

    just store the Toast.makeText( var ) in a variabile like myToast and use cancel() function to remove it.

    let myToast = Toast.makeText( var ); // show() function shouldn't be used here!
    myToast.show(); 
    
    ...
    
    myToast.cancel();