title: Get Current Location From Android Background Service Issue
body: <p>I want to develop location based reminder app. Therefore I want to use android service for get current location even app is not running. But I didn't do. I set timer in android service class but I don't know how to get current location in service class. What is the problem ? I got some error like this:</p>
  
  <p><strong>can't create handler inside thread that has not called looper.prepare()</strong></p>
  
  <pre><code>public class TrackerService extends Service {
  
      double latShared;
      double lngShared;
      double latService;
      double lngService;
      private LocationManager lm;
      Timer timer;
      Handler handler;
      final static long TIME = 15000;
      SharedPreferences mSharedPrefs;
      SharedPreferences.Editor mPrefsEditor;
  
  
  
      @Override
      public IBinder onBind(Intent intent) {
          // TODO Auto-generated method stub
          return null;
      }
  
      @Override
      public void onCreate() {
          mSharedPrefs = getSharedPreferences("locationXML", MODE_PRIVATE);
          latShared = (double)mSharedPrefs.getFloat("lat", 0);
          lngShared = (double)mSharedPrefs.getFloat("lng", 0);
          timer = new Timer();
          timer.schedule(new TimerTask(){
              @Override
              public void run(){
                  LocationUpdates();
              }
          },0,TIME);
  
      }    
  
      public void LocationUpdates(){
          locListener locList = new locListener();
          lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);   
          lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locList);
      }
  
      @Override
      public void onDestroy() {
          //lm.removeUpdates(this);
          timer.cancel();
      }
  
      public class locListener implements LocationListener{
  
          @Override
          public void onLocationChanged(Location location) {
              latService = location.getLatitude();
              lngService = location.getLongitude();
          }
  
          @Override
          public void onProviderDisabled(String provider) {}
  
          @Override
          public void onProviderEnabled(String provider) {}
  
          @Override
          public void onStatusChanged(String provider, int status, Bundle extras) {}
  
  
      }
  
  }
  </code></pre>