Creating your own broadcast messages

As you probably remember, we did code refactoring for the NoteActivity class. Let's show the last state we had in important parts for our further demonstration:

     class NoteActivity : ItemActivity() { 
       ... 
       private val locationListener = object : LocationListener { 
         override fun onLocationChanged(p0: Location?) { 
           p0?.let { 
                LocationProvider.unsubscribe(this) 
                location = p0 
                val title = getNoteTitle() 
                val content = getNoteContent() 
                note = Note(title, content, p0) 
 
                // Switching to intent service. 
                val dbIntent = Intent(this@NoteActivity,                DatabaseService::class.java) 
                dbIntent.putExtra(DatabaseService.EXTRA_ENTRY, note) 
                dbIntent.putExtra(DatabaseService.EXTRA_OPERATION, MODE.CREATE.mode) startService(dbIntent) sendMessage(true) ...

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.