title: Finish android activity from another with Kotlin
body: <p>I'm trying to finish an activity from another (android) with kotlin. I know the wat to do it with java is with the following code (<a href="https://stackoverflow.com/a/10379275/7280257">https://stackoverflow.com/a/10379275/7280257</a>)</p>
  
  <p>at the first activity:</p>
  
  <pre><code>BroadcastReceiver broadcast_reciever = new BroadcastReceiver() {
  
      @Override
      public void onReceive(Context arg0, Intent intent) {
          String action = intent.getAction();
          if (action.equals("finish_activity")) {
              finish();
              // DO WHATEVER YOU WANT.
          }
      }
  };
  registerReceiver(broadcast_reciever, new IntentFilter("finish_activity"));
  </code></pre>
  
  <p>On the other activity:</p>
  
  <pre><code>Intent intent = new Intent("finish_activity");
  sendBroadcast(intent);
  </code></pre>
  
  <p>For some reason converting the java activity to kotlin doesn't give a valid output, if someone could give me the correct syntax to do it properly with <strong>kotlin</strong> I will appreciate it</p>
  
  <p>kotlin output (first activity) <strong>[OK]</strong>:</p>
  
  <pre><code>val broadcast_reciever = object : BroadcastReceiver() {
  
      override fun onReceive(arg0: Context, intent: Intent) {
          val action = intent.action
          if (action == "finish_activity") {
              finish()
              // DO WHATEVER YOU WANT.
          }
      }
  }
  registerReceiver(broadcast_reciever, IntentFilter("finish_activity"))
  </code></pre>
  
  <p>kotlin output (2nd activity) <strong>[OK]</strong></p>
  
  <pre><code>            val intent = Intent("finish_activity")
              sendBroadcast(intent)
  </code></pre>
  
  <p>ERROR: <a href="https://i.imgur.com/qaQ2YHv.png" rel="nofollow noreferrer">http://i.imgur.com/qaQ2YHv.png</a></p>
  
  <p><strong>FIX: THE CODE SHOWN IS RIGHT, YOU JUST NEED TO PLACE IT INSIDE THE onCreate FUNCTION</strong> </p>