Created LocationDao in service.
This commit is contained in:
parent
33ccb30f8a
commit
3b30dd585f
|
|
@ -12,11 +12,13 @@ import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.location.LocationManagerCompat;
|
import androidx.core.location.LocationManagerCompat;
|
||||||
|
import androidx.room.Room;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LocationLoggingService extends Service implements LocationListener {
|
public class LocationLoggingService extends Service implements LocationListener {
|
||||||
private final String TAG = LocationLoggingService.class.getName();
|
private final String TAG = LocationLoggingService.class.getName();
|
||||||
|
private LocationDao locationDao;
|
||||||
|
|
||||||
public LocationLoggingService() {
|
public LocationLoggingService() {
|
||||||
}
|
}
|
||||||
|
|
@ -30,6 +32,12 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
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.");
|
||||||
|
|
||||||
|
LocationDatabase database = Room
|
||||||
|
.databaseBuilder(getApplicationContext(), LocationDatabase.class, "location")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
locationDao = database.locationDao();
|
||||||
|
|
||||||
subscribeToLocationUpdates(this);
|
subscribeToLocationUpdates(this);
|
||||||
|
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue