Hello,

I was browsing the source code to an Android app, and noticed the
following pattern:

public class LocalBinder extends Binder {
  FooService getService() {
    return FooService.this;
  }
}
private Binder mBinder = new LocalBinder();

public IBinder onBind(Intent intent) {
  return mBinder;
}


  .... some time later ....

private FooService mService;
private ServiceConnection mConnection = new ServiceConnection() {
  public void onServiceConnected(ComponentName className, IBinder
service) {
   mService = ((LocalBinder)service).getService();
  }
}

In other words, it just completely opts out of AIDL and the rest, in
favor of passing pointers around. I didn't realise you could do this.
I know that services run in the same process and this is mentioned in
the docs, but is this guaranteed to always be true going forward? If
so, let's document it, as this is a massive time saving trick for
services that aren't intended to be exposed outside the application
(which I guess is a lot of them).

thanks -mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to