Re: In-App Billing example service lifecycle
markusn82 <markusn82 <at> gmail.com>
2011-04-21 15:00:49 GMT
Good point. I did try to terminate the service manualls via
stopService after the unbind in BillingService. This seems to work in
terminating the service when the application exits, but I may be
breaking Service conventions since bound services are suppose to stop
On Apr 20, 9:46 am, Kostya Vasilyev <kmans... <at> gmail.com> wrote:
> 20.04.2011 17:32, markusn82 пишет:
> > I tried out several other applications with In-App billing (Dungeon
> > Defenders and Comics) and they suffered from the same issue.
> > Are there any official responses from the Android team about this
> > undocumented way of starting a service?
> If you mean this list, well, we're both here, and I don't see any, do
> you? :)
> Don't see any in the issue I filed, either.
> -- Kostya
> > On Apr 19, 3:51 pm, Kostya Vasilyev<kmans... <at> gmail.com> wrote:
> >> Mark,
> >> The calls to startService in BillingService are matched by stopSelf(),
> >> so that's not the cause.
> >> I believe this long-running service is caused by how the purchase
> >> activity starts the billing service:
> >> Dungeons.java
> >> mBillingService = new BillingService();
> >> mBillingService.setContext(this);
> >> I don't see anything in the documentation to support that this is a
> >> proper way to start a service.
> >> Bug report:
> >> The call to unbindService in Dungeons.onDestroy is a bit of a red herring:
> >> The "this" in "unbindService(this)" is BillingService.this as a
> >> ServiceConnection.
> >> Therefore, the code unbinds the Vending service (inside Market) from the
> >> Billing service (inside the application), releasing the former, but does
> >> nothing to stop the latter.
> >> -- Kostya
> >> 19.04.2011 22:30, markusn82 пишет:
> >>> 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
> >>> 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
> >> --
> >> Kostya Vasilyev --http://kmansoft.wordpress.com
> Kostya Vasilyev --http://kmansoft.wordpress.com
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 <at> googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe <at> googlegroups.com
For more options, visit this group at