title: Android - using LocationManager does not give a geo fix
body: <p>I am trying to get the GPS location of my G1 using the following code</p>
  
  <p><strong>In Activity</strong></p>
  
  <pre><code>MyLocationListener myListener = new MyLocationListener();
  LocationManager myManager = (LocationManager)getSystemService(LOCATION_SERVICE);
  myManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 0, myListener);
  </code></pre>
  
  <p>This is the LocationListener class</p>
  
  <pre><code>public class MyLocationListener implements LocationListener {
  
    private static double latitude;
    private static double longitude;
  
    @Override
    public void onLocationChanged(Location arg0) {
      latitude = arg0.getLatitude();
      longitude = arg0.getLongitude();
    }
  
    @Override
    public void onProviderDisabled(String provider) {
    }
  
    @Override
    public void onProviderEnabled(String provider) {
    }
  
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {}
  
    public static double getLatitude() {
      return latitude;
    }
  
    public static double getLongitude() {
      return longitude;
    }
  
  }
  </code></pre>
  
  <p>I waited for as long as 30 seconds but none of the listener methods were called. The GPS icon shows up, stays there for some time but for some reason I don't get a fix, even outdoors in bright sunlight. I am testing on a G1 with 1.5 SDK.</p>
  
  <p>Can someone please tell me what's wrong with the code? Thanks.</p>
  
  <p>Adding log</p>
  
  <pre><code>06-02 18:30:43.143: ERROR/System(52): java.lang.SecurityException
  06-02 18:30:43.143: ERROR/System(52):     at android.os.BinderProxy.transact(Native Method)
  06-02 18:30:43.143: ERROR/System(52):     at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
  06-02 18:30:43.143: ERROR/System(52):     at android.os.ServiceManager.addService(ServiceManager.java:72)
  06-02 18:30:43.143: ERROR/System(52):     at com.android.server.ServerThread.run(SystemServer.java:155)
  06-02 18:30:43.152: ERROR/AndroidRuntime(52): Crash logging skipped, no checkin service
  
  06-02 18:30:43.382: ERROR/SystemServer(52): Failure starting StatusBarService
  06-02 18:30:43.382: ERROR/SystemServer(52): java.lang.NullPointerException
  06-02 18:30:43.382: ERROR/SystemServer(52):     at com.android.server.status.StatusBarPolicy.updateBluetooth(StatusBarPolicy.java:749)
  06-02 18:30:43.382: ERROR/SystemServer(52):     at com.android.server.status.StatusBarPolicy.&lt;init&gt;(StatusBarPolicy.java:282)
  06-02 18:30:43.382: ERROR/SystemServer(52):     at com.android.server.status.StatusBarPolicy.installIcons(StatusBarPolicy.java:337)
  06-02 18:30:43.382: ERROR/SystemServer(52):     at com.android.server.ServerThread.run(SystemServer.java:186)
  06-02 18:30:43.382: ERROR/AndroidRuntime(52): Crash logging skipped, no checkin service
  </code></pre>