title: How to listen BroadcastReceiver in main activity?
body: <p>I have broadcast in separated class:</p>
  <pre><code>class Receiver : BroadcastReceiver() {
      override fun onReceive(context: Context, intent: Intent) {}
  }
  </code></pre>
  <p>How to listen this broadcasrt in main activity?</p>
  <p>I have tried:</p>
  <pre><code>class MainActivity :  AppCompatActivity() {
      private val receiver = Receiver()
      override fun onCreate(savedInstanceState: Bundle?) {
          receiver.onReceive(context: Context, intent: Intent) {
            //
          }
      }
  }
  </code></pre>
  <p>Now I register events like this:</p>
  <pre><code>override fun onStart() {
      super.onStart()
      registerReceiver(receiver, IntentFilter(TelephonyManager.ACTION_PHONE_STATE_CHANGED))
  }
  </code></pre>
  <p>I tried this in activity:</p>
  <pre><code>private val broadcastReceiver:BroadcastReceiver = (object :BroadcastReceiver(){
      override fun onReceive(context: Context, intent: Intent) {
  
          val ltInflater = layoutInflater
          val layout: View = ltInflater.inflate(R.layout.custom_toast, findViewById(R.id.toast_layout))
          val image = layout.findViewById&lt;ImageView&gt;(R.id.imageView)
  </code></pre>
  <p>}</p>
  <p>So, I get error because I can not get access to layout in this step</p>