title: Get Context in Android library
body: <p>I'm writing an Android app that has some functionality encapsulated in an internal library. However, for this functionality to work, the library needs an instance of the Application Context. What's the best way to give the library this Context? I see a few options, none of them appealing:</p>
  
  <ul>
  <li>Have my library classes extend <code>Application</code>, and call <code>getApplicationContext()</code> 
  <ul>
  <li>This is generally discouraged</li>
  </ul></li>
  <li>Have my library classes each implement the singleton pattern, and have each caller pass in a <code>Context</code> each time they get a reference to the singleton.
  <ul>
  <li>This requires every caller to retrieve the Application Context before using the library, and also requires that the caller call against an <em>instance</em> of the library instead of against static methods defined on the library class (and thus further requires keeping a reference to this instance).</li>
  </ul></li>
  </ul>