Changes

Jump to: navigation, search

Kotlin Android Broadcast Intents and Broadcast Receivers

128 bytes removed, 16:27, 4 December 2017
Creating the Broadcast Receiver
This concludes the creation of the application to send the broadcast intent. All that remains is to build a matching broadcast receiver.
== Creating Creating the Broadcast Receiver ==
In order to create the broadcast receiver, a new class needs to be created which subclasses the BroadcastReceiver superclass. Within the Project tool window, navigate to app -> java and right-click on the package name. From the resulting menu, select the New -> Other -> Broadcast Receiver menu option, name the class MyReceiver and make sure the Exported and Enabled options are selected. These settings allow the Android system to launch the receiver when needed and ensure that the class can receive messages sent by other applications on the device. With the class configured, click on Finish.
 
    override fun onReceive(context: Context, intent: Intent) {
        // TODO: This method is called when the BroadcastReceiver is receiving        // an Intent broadcast.       
        throw UnsupportedOperationException("Not yet implemented")
 

Navigation menu