Let's say I have this code in onCreate()
for (int i = 0; i < 20; i++) {
Toast.makeText(MainActivity.this, "Toast "+i, Toast.LENGTH_SHORT).show();
}
when I launch the app, Toasts start to pop up.
now, when I press the back button(let's say after Toast 5). The onDestroy() is called, app is closed.
But I can still see the Toast popping up until it reaches to 20 or I clear app from memory.
Question:
Why my code is running out of the app?
I had given the context of my activity, then shouldn't it stop as soon as the activity is destroyed?
Doesn't the context matter here?
It would be helpful if you link any documentation.