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);
|
return new LocationLoggingServiceBinder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.d(TAG, "Service started.");
|
Log.d(TAG, "Service started.");
|
||||||
|
|
||||||
LocationManager locationManager = (LocationManager) getSystemService(Service.LOCATION_SERVICE);
|
subscribeToLocationUpdates(this);
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
|
|
||||||
|
|
||||||
return super.onStartCommand(intent, flags, startId);
|
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
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "Service has been destroyed.");
|
Log.d(TAG, "Service has been destroyed.");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue