Created direct method on service binder.
This commit is contained in:
parent
77e343bfbb
commit
ce6c090d19
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue