Take the 2-minute tour ×

I am developing a application in android. I want a toast to be displayed only once when an activity is first created but the toast is displayed every time screen orientation changes......any idea how to do this.....

share|improve this question

1 Answer 1

When the user changes the screen orientation, by default, the activity is completely destroyed and re-created.

You can override this behavior by handling the change yourself.

This is a lot of work for something as simple as a toast. Typically you would do this only if your activity had a lot of initialization that it had to do, such as opening large databases, making network connections, etc.

If it really is something as simple as a toast, and will stay that way, just set a preference after you display the toast, and check the value of the preference before you display it.

share|improve this answer

Your Answer


