Tuesday, April 19, 2011

[android-developers] In-App Billing example service lifecycle

Hi,

I recently implemented In-App billing for an application and I used
the Dungeons example as a starting point. I noticed that after leaving
my application (onDestroy is called in the base stack activity), the
BillingService service is still running on the phone and stays running
long after. I made sure that I was unbinding from the BillingService
service during onDestroy of my base activity.

As I understand it, a service that is started with startService needs
to be stopped with stopService/stopSelf, even if components bind/
unbind to it during its lifecycle (See
http://developer.android.com/guide/topics/fundamentals/bound-services.html#Lifecycle).
Does this mean that stopSelf should be called manually after calling
unbindService() or should the service stop itself automatically?

I looked further into the example code and saw that the BillingService
service was being started with startService, but stopService/stopSelf
was not being called ever. The call to stopSelf does exist in code but
it is never executed during the lifecycle of the application. Does
this indicate a bug in the example code or perhaps a bug in my usage.
I noticed that the Dungeon example app itself also experiences the
same problem (service still running after application exited).

Any help would be appreciated.

Thanks,

Mark


--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate