This website or its third-party tools use cookies which are necessary to its functioning and required to improve your experience. By clicking the consent button, you agree to allow the site to use, collect and/or store cookies.
Please click the consent button to view this website.
I accept
Deny cookies Go Back

Mobile app tutorials

  • Home
  • About
  • Contact
  • Login
You are here: Home / Kotlin Fragments / Kotlin sharing data using fragment arguments

December 13, 2017 by nigel

Kotlin sharing data using fragment arguments





The Kotlin sharing data using fragment arguments Android development tutorial describes how to pass data from an Android activity to a fragment using arguments.

This Kotlin on Android tutorial follows directly on from the passing data from android fragment to activity tutorial.

The recorded Uri from the previous tutorial will be passed from the main activity to a new Android fragment. Which will load the Uri into a VideoView for playback.

The video playback portion of the Kotlin on Android tutorial will be based on the Kotlin VideoView tutorial.

If you are new to Android and/or Kotlin I recommend the Kotlin Fragments series to be done prior to this Kotlin on Android tutorial.

The key concepts this Kotlin on Android tutorial will cover are

  1. Creating Android Fragments including layout files
  2. How to load an Android fragment from an Android activity
  3. How to switch from one Android fragment to another Android fragment
  4. How to pass data from an Android activity to fragment
  5. How to impement a VideoView in an Android fragment

Episodes

  1. Fragment Interface
  2. Fragment Arguments
  3. ViewModel
To get access to the source code and code descriptions please fill out the form below to complete your free membership:
An account with your username and/or email address has been created. Log in here to access your products or complete a purchase. [Note: an account will be created even if your initial transaction failed at checkout. If this happened to you, simply log in and attempt your transaction again.]









Conclusion

In the Kotlin fragment arguments data share Android development tutorial, we described how to pass data from an Android activity to an Android fragment.

Inside the VideoViewFragment the fragment’s argument value was used to save the Uri. Which could then be reused inside the fragment lifecycle.

A basic VideoView was also implemented inside the Android fragment, for video playback.

As demonstrated in this and the previous tutorial, a significant amount of code was required for the implementation for sharing data between Android fragments.

In the following tutorial, we will describe an alternative approach, using the Android ViewModel.

Print Friendly

Filed Under: Kotlin Fragments Tagged With: Android, Android Development Tutorials, Android Fragment, Android Studio, Fragment, Fragment Android, Kotlin, Kotlin Fragment Argument, Kotlin Fragment Arguments, Sharing Data

  • Facebook
  • Google+
  • Twitter
  • YouTube




Recent Forum Topics

  • Kotlin Fragments
  • Kotlin Camera2 API
  • HTTP Image Libraries

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Recent Posts

  • Installing and running flutter
  • Kotlin Camera2 API MediaRecorder
  • Flutter IntelliJ Tips for Beginners
  • Migrating Fragments to Jetpack Navigation
  • Flutter TabBar

Search Form

  • Facebook
  • GitHub
  • Google+
  • Twitter
  • YouTube

© 2022 - WWW.MOBAPPTUTS.COM