You know that, in android, an activity has a lifecycle associated with them, activities receive their own input events. Like an activity, a fragment too has a lifecycle associated with them and receives its own input events. So, You can call a fragment a sub-activity. You can add a fragment…