Search⌘ K
AI Features

Launch Second Screen

Explore how to implement screen navigation in an Android app with Kotlin. Learn to simulate a login delay using Handler, create an Intent to launch a new activity, and close the previous one to manage the app's back stack effectively.

Flow overview

When a user clicks the login button we will perform a data validation flow, and if the data is valid, proceed to:

  1. Simulate long-running operation for 2 seconds
  2. Open MainActivity
  3. Finish LoginActivity

Simulate a long-running operation

In this lesson, we are not going to do a real login HTTP call, so let’s just simulate it via delay of 2 seconds before opening MainActivity. In a real application, we would need to ...