Track the lifecycle of the activity.