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

Fragment lifecycles

Activities can contain Fragments--self-contained units that contain views and have a lifecycle of their own. However, the lifecycle of a Fragment is bound to the Activity that contains it, so they are also tightly related.

The lifecycle can be seen in the following figure:

A very good briefing and explanation about Fragments can be found at https://developer.android.com/guide/components/fragments.html.

We can see that this is very similar to the lifecycle of an Activity, but there are a few new methods, such as the following:

  • onAttach()
  • onCreateView()
  • onActivityCreated()
  • onDestroyView()
  • onDetach()

It is beyond the scope ...

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