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, NoteActivity::class.java) val data = Bundle() data.putInt(MODE.EXTRAS_KEY, MODE.CREATE.mode) intent.putExtras(data) 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, TodoActivity::class.java) val data = Bundle() data.putInt(MODE.EXTRAS_KEY, MODE.CREATE.mode) data.putString(TodoActivity.EXTRA_DATE, dateFormat.format(date...