1

I have a service I'm using to synchronize my contacts and I wanted to add some more methods to it (I didn't create this service, I'm just extending it and I'm a bit lost). I'll call these methods in certain circumstances, so I'm gonna need the service instance to do these calls. I see that in Android Developers they create the class LocalBinder with the method getService() to get this instance, but I'm using an AbstractThreadedSyncAdapter:

private AbstractThreadedSyncAdapter mSyncAdapter = null;

public IBinder onBind(Intent intent) {
    return getSyncAdapter().getSyncAdapterBinder();
}

private synchronized AbstractThreadedSyncAdapter getSyncAdapter() {
    if (mSyncAdapter == null) {
        mSyncAdapter = new MyContactSync(this, true);
    }
    return mSyncAdapter;
}

First of all, should I create another service to implement this methods or I can use the same that's doing the synchronization? If I can use the same, how can I get the service instance?

Onik
  • 19,396
  • 14
  • 68
  • 91
PX Developer
  • 8,065
  • 7
  • 42
  • 66

0 Answers0