Added a method to get all locations.
This commit is contained in:
parent
9e989684a1
commit
046d1d3a26
|
|
@ -2,9 +2,15 @@ package com.proculite.logmylocation;
|
||||||
|
|
||||||
import androidx.room.Dao;
|
import androidx.room.Dao;
|
||||||
import androidx.room.Insert;
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.Query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
public interface LocationDao {
|
public interface LocationDao {
|
||||||
@Insert
|
@Insert
|
||||||
void insert(LocationEntity location);
|
void insert(LocationEntity location);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM locationentity")
|
||||||
|
List<LocationEntity> getAll();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,10 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
return super.onStartCommand(intent, flags, startId);
|
return super.onStartCommand(intent, flags, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LocationEntity> allLocations(){
|
||||||
|
return locationDao.getAll();
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressLint("MissingPermission")
|
@SuppressLint("MissingPermission")
|
||||||
public void subscribeToLocationUpdates(LocationListener locationListener)
|
public void subscribeToLocationUpdates(LocationListener locationListener)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ package com.proculite.logmylocation;
|
||||||
import android.location.LocationListener;
|
import android.location.LocationListener;
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LocationLoggingServiceBinder extends Binder {
|
public class LocationLoggingServiceBinder extends Binder {
|
||||||
private final LocationLoggingService service;
|
private final LocationLoggingService service;
|
||||||
|
|
||||||
|
|
@ -17,4 +19,8 @@ public class LocationLoggingServiceBinder extends Binder {
|
||||||
public void subscribeToLocationUpdates(LocationListener locationListener){
|
public void subscribeToLocationUpdates(LocationListener locationListener){
|
||||||
this.service.subscribeToLocationUpdates(locationListener);
|
this.service.subscribeToLocationUpdates(locationListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LocationEntity> allLocations(){
|
||||||
|
return this.service.allLocations();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue