Added subscribeToLocationUpdates method.
This commit is contained in:
parent
3b40094457
commit
66381cacf4
|
|
@ -26,17 +26,22 @@ public class LocationLoggingService extends Service implements LocationListener
|
|||
return new LocationLoggingServiceBinder(this);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.d(TAG, "Service started.");
|
||||
|
||||
LocationManager locationManager = (LocationManager) getSystemService(Service.LOCATION_SERVICE);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
||||
subscribeToLocationUpdates(this);
|
||||
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
public void subscribeToLocationUpdates(LocationListener locationListener)
|
||||
{
|
||||
LocationManager locationManager = (LocationManager) getSystemService(Service.LOCATION_SERVICE);
|
||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.d(TAG, "Service has been destroyed.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue