Member-only story

Android Compose: App Navigation how to Pass Data Between Screens

Andres Sandoval
5 min readDec 11, 2024

--

Compose series

Part 1: Compose Basics (WIP)

Part 2: Android Compose: App Navigation

Part 3: Android Compose: App Navigation how to Pass Data Between Screens

Part 4: Android Compose: Building a Simple Image Loading App with MVVM

Part 5: Android Compose: Building a Modern Android App with MVVM, Navigation, and Retrofit

This tutorial shows how to pass data between two screen. Continuation of the blog post: Android app Navigation with Compose — part 1 This code is a Jetpack Compose application with a simple navigation structure that demonstrates how to pass data between screens. Here’s an overview:

Code Execution Flow

App Launch:

  • MainActivity initializes and loads the ComposeNavigationApp Composable.

Home Screen:

  • The user sees the Home Screen with a text field and a button.
  • They enter their name and click “Go to Details.”

Navigation to Details Screen:

  • The navController navigates to the "details/{name}" route, passing the entered name as an argument.

Details Screen:

  • The name argument is retrieved and displayed as part of a welcome message.
  • The user can click “Go to Home” to navigate back to the Home Screen.

Purpose

The app consists of two screens:

  1. Home Screen: Allows the user to enter their name and navigate to the “Details Screen.”

2. Details Screen: Displays a welcome message including the entered name and provides a button to navigate back to the “Home Screen.”

To pass the name value from the HomeScreen to the DetailsScreen, you can use the arguments functionality in Jetpack Compose Navigation.

Key Updates
Passing Arguments:

--

--

Andres Sandoval
Andres Sandoval

Written by Andres Sandoval

I'm a passionate Android Software Engineer with over 11 years of experience. andresand.github.io/andres-about-me/ buymeacoffee.com/andresand

No responses yet

Write a response