62.8 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.
Once created, Android Studio will automatically load the new MyReceiver.kt class file into the editor where it should read as follows:
package com.ebookfrenzy.sendbroadcast
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
class MyReceiver : BroadcastReceiver() {
...