You do not need a "remote" service within a single application, as
your sample illustrates. While you can use AIDL and binding for local
services, it's unclear if there are any benefits compared to just
using a local Binder. Remote services -- where the client and service
are in separate applications -- *do* need AIDL if you want to use the
binding pattern.

Also, using setClassName() as you have it is an anti-pattern. For
local services, use the constructor that takes the actual class. For
remote services, the service should publish an <intent-filter> that is
stable (e.g., using a custom action string). Even better is to publish
one <intent-filter> per version of the exported API. Your code as
written will break when the service author refactors their code, and
the service has no way to know which version of the service's API the
client wants to receive.

Also, your client (Activity) never unbinds from the service, which is
bad form. If you bind to the service, unbind from it. If the service
is supposed to live past the end of the client's life, you should be
using startService().

On Tue, May 31, 2011 at 7:45 AM, Jignesh Kakkad(Jiggy)
<jig2n...@gmail.com> wrote:
> Hi Guys,
> I thought this sample code would be useful to someone.
> http://tips-tricks.weblogforfun.com/2011/05/31/creating-remote-background-service/
> Please feel free to comment on the same (if you think there is any other way
> to improve it)
> Thanks
> Regards
> Jiggy
> Mobile news:
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training in NYC: http://marakana.com/training/android/

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

Reply via email to