Created direct method on service binder.

This commit is contained in:
Filip Strajnar 2024-10-19 14:22:12 +02:00
parent 77e343bfbb
commit ce6c090d19
2 changed files with 7 additions and 2 deletions

View file

@ -1,9 +1,10 @@
package com.proculite.logmylocation;
import android.location.LocationListener;
import android.os.Binder;
public class LocationLoggingServiceBinder extends Binder {
public final LocationLoggingService service;
private final LocationLoggingService service;
public LocationLoggingServiceBinder(LocationLoggingService service){
this.service = service;
@ -12,4 +13,8 @@ public class LocationLoggingServiceBinder extends Binder {
public LocationLoggingService getService(){
return this.service;
}
public void subscribeToLocationUpdates(LocationListener locationListener){
this.service.subscribeToLocationUpdates(locationListener);
}
}

View file

@ -68,7 +68,7 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
Log.d(TAG, "Service connected.");
LocationLoggingServiceBinder binder = (LocationLoggingServiceBinder) iBinder;
binder.getService().subscribeToLocationUpdates(this);
binder.subscribeToLocationUpdates(this);
}
@Override