O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Things to know about onCreate() calls

At first, it might look that onCreate() is very straightforward--it gets called only once when an Activity gets created. However, the tricky bit is that an Activity can get destroyed and created not just when it is actually started (with startActivity()).

An Activity will also be destroyed and created in the following cases:

  • A device is rotated so that the orientation changes from landscape to portrait or vice versa
  • A system language changes
  • On Android 7.0, in multiple Activity or Application configurations, an Activity's space is resized
  • Hardware keyboard is popped out

In all of these cases, the currently running Activity will be destroyed and created with a new configuration as a completely new instance ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required