title: Good to have a static reference to foreground activity?
body: <p>Is it good practice to have a static reference to foreground activity? eg:  </p>
  
  <pre><code>public static Activity currentActivity = null;
  </code></pre>
  
  <p>This question is straight forward but I could not find much information on that. I am doing Xamarin Android - writing android apps in C#, so I get lots of tasks (background thread), and I wanna make a dialog but I do not have reference to the foreground activity whatsoever. </p>
  
  <p>So what I am doing now is have a static reference to it, setting and unsetting the reference inside activitylifecyclecallbacks so it gets triggered at every activity, then putting a mutex around setter of the reference to ensure safety under extremely weird conditions..</p>
  
  <p>This seems a bit hackish to me, but getting the current activity is really unnecessarily hard, and the methods I am dealing with are defined by interfaces used by IocContainers across all WPF, Android, iOS apps so I really cant pass activities around because I cant change method signatures.</p>