title: How do you call a method in an activity from a broadcastreceiver that is registered in manifest without starting the activity with an intent?
body: <p>I have a extended broadcastreceiver class that listens for bluetooth connection/disconnection. I want it to change a color of some text in my GUIActivity. I don't have it as an inner class on purpose: to keep the GUI code more manageable/modular. </p>
  
  <p>I know of one way to do this: register the receiver dynamically and pass it in the context of the activity. Then do the normal registering/unregistering in onResume and onPause. This solution can be seen at <a href="https://stackoverflow.com/questions/16934425/call-an-activity-method-from-a-broadcastreceiver-class?lq=1">this post</a></p>
  
  <p>However, I was hoping I could eliminate just a little bit more code by having my receiver registered in the manifest and not worry about registering/unregistering. </p>
  
  <p>I have tried casting the <strong>context</strong> in the onReceive on the Broadcastreceiver as follows</p>
  
  <pre><code>((SmokinoGUI) context).indicateBTConnection();
  </code></pre>
  
  <p>This throws an exception saying that context cannot be cast to SmokinoGUI. indicateBTConnection() is a method in the SmoinoGUI activity that does what it says. </p>
  
  <p>So, is there a way to call a method in an activity from a broadcastreceiver that has been registered in the manifest and has not been dynamically instantiated?</p>