title: Android Context without being in an activity? And other activity-less programming?
body: <p>I'll try really hard to turn this into one comprehensive question:</p>
  
  <p>I'm writing a method to get a String that contains the name of an Android device's city, as determined by the <code>LocationManager</code> and <code>getLastKnownLocation()</code> and all that.</p>
  
  <p>Then I realized I'd need to do the same thing again in another activity, so why not just make an entirely separate class (<code>LocationFinder</code>) that I could use across my program, instead of writing duplicate code everywhere?</p>
  
  <p>But I've run into problems that confuses me.  For instance, if I make this class (<code>LocationFinder</code>), should it extend Activity, even though it is never actually visualized?  All this class would do is have a variety of getters like <code>getLastKnownCity()</code> or <code>getCurrentCity()</code> and return strings.  I assumed it wouldn't HAVE to extend the Activity class, since it's really not an activity.</p>
  
  <p>But then what Context do I use for:</p>
  
  <pre><code>Geocoder geocoder = new Geocoder(Context context, Locale locale)
  </code></pre>
  
  <p>?</p>
  
  <p>This made me assume it MUST be an activity.  So I extended Activity, and replaced the constructor with</p>
  
  <pre><code>@Override
  protected void onCreate(..............
  </code></pre>
  
  <p>but for some reason, that never ends up getting called, even when I put</p>
  
  <pre><code>String city = new LocationFinder().getLastKnownCity();
  </code></pre>
  
  <p>My very first line of <code>LocationFinder</code>'s <code>onCreate()</code> is</p>
  
  <pre><code>System.out.println("HEY!")
  </code></pre>
  
  <p>and it never even gets to that.  I get a null pointer at <code>android.internal.os.LoggingPrintStream.println()</code> and other stuff.</p>
  
  <p>Plus, there's a bunch of system constants that come from Activity classes.  For instance, I need to get at <code>LOCATION_SERVICE</code>, which is a String, which I can't get without extending Activity.  Sure, I could cheat and just put in the literal string, but that feels wrong.</p>