title: Calling function from the MainActivity scope
body: <p>In my Android app, I defined a function within the <code>MainActivity</code> scope, as:</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
       fun connectWebSocket() { }
  }
  </code></pre>
  
  <p>This is because I want to use the <code>runOnUiThread</code> in my <code>connectWebSocket()</code> function.</p>
  
  <p>In another <code>BroadcastReceiver()</code> I'm trying to call this <code>connectWebSocket()</code> as:</p>
  
  <pre><code>class MyLocationService : BroadcastReceiver() {
      connectWebSocket()
  }
  </code></pre>
  
  <p>But I failed and got this error:</p>
  
  <blockquote>
    <p>Unresolved Reference: connectWebSocket</p>
  </blockquote>
  
  <p>How can I fix it?</p>