Passing information between activities and fragments

To pass information between our activities, we will use the Android Bundle. Bundle can contain multiple values of different types. We will illustrate the use of Bundle by extending our code. Open ItemsFragemnt and update it as follows:

    private fun openCreateNote() { 
      val intent = Intent(context, 
      val data = Bundle() 
      data.putInt(MODE.EXTRAS_KEY, MODE.CREATE.mode) 
      startActivityForResult(intent, NOTE_REQUEST) 
    }  private fun openCreateTodo() { val date = Date(System.currentTimeMillis()) val dateFormat = SimpleDateFormat("MMM dd YYYY", Locale.ENGLISH) val timeFormat = SimpleDateFormat("MM:HH", Locale.ENGLISH) val intent = Intent(context, ...

Get Mastering Android Development with Kotlin now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.