This is my sample code:
public class MainActivity extends Activity {
Button buttonClick;
@Override
protected void onCreate(Bundle savedInstanceS
I want if the application is closed then Toast should also stop displaying the message.
In your case call cancel() to Toast object to cancel it within onDestroy() method.
Here is a similar example.
Updated!
I tested OP solution but no result.
.hide() and .cancel() method is available for Toast but seem they are not working. The solution is, you have to create your own custom view which acts like a Toast and then you can cancel all Toasts when the Activity finishes.