title: Location service does not work in a real android device
body: <p>My test app that finds current location of the device is working fine in emulator. That is, when in my DDMS in eclipse, I send the location coordinates to the emulator, the app catches the broadcast and displays the location in the map in emulator. But in my real 2.3.3 android device, the app just hangs while gps is blinking in notification bar. Here is what I am doing in my service class</p>
  
  <pre><code>public void onStart(Intent intent, int startId) {
      super.onStart(intent, startId);
      Log.e("&lt;&lt;MyGpsService-onStart&gt;&gt;", "GPS starting...");
      triggerService = new Thread(new Runnable() {
          public void run() {
              try {
                  Looper.prepare();
                  lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
                  myLocationListener = new GPSListener();
                  long minTime = 10000; // frequency update: 10 seconds
                  float minDistance = 50; // frequency update: 50 meter
                  lm.requestLocationUpdates(
                          // request GPS updates
                          LocationManager.GPS_PROVIDER, minTime, minDistance,
                          myLocationListener);
                  Looper.loop();
              } catch (Exception e) {
                  Log.e("MYGPS", e.getMessage());
              }
          }// run
      });
      triggerService.start();
  }
  class GPSListener implements LocationListener {
      public void onLocationChanged(Location location) {
          double latitude = location.getLatitude();
          double longitude = location.getLongitude();
  
          Intent myFilteredResponse = new Intent(GPS_FILTER);
          myFilteredResponse.putExtra("latitude", latitude);
          myFilteredResponse.putExtra("longitude", longitude);
          Log.e("&gt;&gt;GPS_Service&lt;&lt;", "Lat:" + latitude + " lon:" + longitude);
  
          sendBroadcast(myFilteredResponse);
      }
  
      public void onProviderDisabled(String provider) {
      }
  
      public void onProviderEnabled(String provider) {
      }
  
      public void onStatusChanged(String provider, int status, Bundle extras) {
      }
  };// GPSListenerclass
  </code></pre>
  
  <p>I wonder if any of you have a similar problem. Thanks.</p>
  
  <p>UPDATE: I followed following question and answer:</p>
  
  <p><a href="https://stackoverflow.com/questions/3120256/android-reliably-getting-the-current-location">Android - Reliably getting the current location</a></p>
  
  <p>After the change, the app is working a lot better.</p>