From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Pass selected data to a fragment

Pass selected data to a fragment - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Pass selected data to a fragment

- [Instructor] When you navigate from one destination to another with the navigation component, you can choose from a couple of strategies for passing values. The simplest approach is to pass a bundle of key value pairs. But this can be error-prone. You have to know what type of data is being received in the target destination and it's possible to get it wrong resulting in something that compiles, but doesn't work at runtime. Safe Args is a Jetpack library that generates classes with functions and statically typed values for sending receiving values between destinations. You have to set it up in your Gradle files, but then it works for all of your destinations when you're using the navigation component. The first step is to add a couple of lines of code to your top level Gradle build file. On this webpage I'll select these two lines and copy them, then I'll open up my build.gradle file for my project. And I'll…

Contents