Android Fragment is the part of activity, it is also known as sub-activity. There can be more than one fragment in an activity. Fragments represent multiple screen inside one activity.
Android fragment lifecycle is affected by activity lifecycle because fragments are included in activity.
Each fragment has its own life cycle methods that is affected by activity life cycle because fragments are embedded in activity.
The FragmentManager class is responsible to make interaction between fragment objects.
Android Fragment Lifecycle
The lifecycle of android fragment is like the activity lifecycle. There are 12 lifecycle methods for fragment.
Android Fragment Lifecycle Methods
Android Fragment Example
Let's have a look at the simple example of android fragment.