What is the chief purpose of line five in this code snippet?

override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_post_create)

if (savedInstanceState != null) return

val fragment = CreatePostFragment()
supportFragmentManager
.beginTransaction()
.add(R.id. fragment_container, fragment)
.commit()

}

  • to make sure that the activity finishes when the savedInstanceState is not null
  • to make sure that the activity creates a new fragment each time it is restored from a previous state
  • to prevent the display of two fragments side by side in cases where the activity is restored from a previous state
  • to prevent the creation of overlapping fragments in cases where the activity is restored from a previous state
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
G Certification Course We would like to show you notifications for the latest news and updates.
Dismiss
Allow Notifications
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Send this to a friend