How to Get a Reference to LocationManager

public abstract Object getSystemService (String name) was added in API level 1
Return the handle to a system-level service by name. The class of the returned object varies by the requested name.

1. In the MainActivity.java file, Get the Context.LOCATION_SERVICE and save to a string named svcName.

2. In the onCreate method, Declare a LocationManager named myLocationManager.

3. In the onCreate method, add the following line. This will get a reference to the LocationManager saved to myLocationManager.

myLocationManager = (LocationManager)getSystemService(svcName);

4. Compile and run!

Next Recommended Article: How to Get the Name of the GPS Location Provider

Resources:
http://developer.android.com/reference/android/content/Context.html#getSystemService(java.lang.String)