title: could not get interface listener instanced in class
body: <p>listener is unresolved 
  i couldn't get why?
  tried differently but no proper solution </p>
  
  <blockquote>
    <p>can anybody please tell me where is the problem why listener is red colored?</p>
  </blockquote>
  
  <pre><code>interface MessageListener(messageText: String) {
  
  }
  class SmsReceiver(listener: MessageListener) : BroadcastReceiver() {
  
      override fun onReceive(context: Context, intent: Intent) {
          val extras = intent.extras
          lateinit var number:TextView
  
          if(extras != null){
              val sms = extras.get("pdus") as Array&lt;Any&gt;
  
              for(i in sms.indices) {
                  val format = extras.getString("format")
  
                  val smsMessage = if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M) {
                      SmsMessage.createFromPdu(sms[i] as ByteArray, format)
                  } else {
                      SmsMessage.createFromPdu(sms[i] as ByteArray)
                  }
                  val phoneNumber = smsMessage.originatingAddress
                  val messageText = smsMessage.messageBody.toString()
  
                 // Toast.makeText(context, "From: $phoneNumber Message: $messageText", Toast.LENGTH_LONG).show()
                // var a= Toast.makeText(context, "From: $phoneNumber Message: $messageText", Toast.LENGTH_LONG).show()
                //  number.text="$phoneNumber"
                  listener=this.listener
                 listener.onMessageReceived(phoneNumber, messageText)
              }
  
              }
  
          }
  
      companion object {
          class onMessageReceived(public val phoneNumber: String?, private val messageText: String) : listener.onMessageReceived("$phoneNumber $messageText")
      }
  
  }
  </code></pre>