title: Kotlin - passing function as parameter via Intent
body: <p>I have this function in kotlin extension file to pass method but it doesn't work. Please explain me how it make correctly, I try this:</p>
  
  <pre><code>fun showErrorClientScreen(context: Context, action : () -&gt; Unit) {
      val intent = Intent(context, RestClientErrorActivity::class.java)
  
      val bundle = Bundle()
      bundle.putSerializable(UPDATE_CLIENT_ERROR, ErrorClientListener {  action })
      intent.putExtra(UPDATE_CLIENT_ERROR_BUNDLE, bundle)
  
      context.startActivity(intent)
  }
  </code></pre>
  
  <p>use java interface </p>
  
  <pre><code>public interface ErrorClientListener extends Serializable {
  
      void tryAgainFunction();
  
  }
  </code></pre>
  
  <p>and my activity where i need listen click button and try again send request:</p>
  
  <pre><code>class RestClientErrorActivity: BaseActivity(), View.OnClickListener {
  
      private lateinit var errorClientListener: ErrorClientListener
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_rest_client_error)
  
          try {
              val bundle = intent.getBundleExtra(UPDATE_CLIENT_ERROR_BUNDLE)
              errorClientListener = bundle?.getSerializable(UPDATE_CLIENT_ERROR) as ErrorClientListener
          } catch (e: Exception) {
              e.message
          }
      }
  
      override fun onClick(v: View?) {
          when (v?.id) {
              R.id.ib_update -&gt; errorClientListener.tryAgainFunction()
          }
      }
  
  }
  </code></pre>