markusn82 | 19 Apr 20:30 2011
Picon

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

(Continue reading)

Kostya Vasilyev | 19 Apr 21:51 2011
Picon

Re: In-App Billing example service lifecycle

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:

http://code.google.com/p/marketbilling/issues/detail?id=8

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
(Continue reading)

markusn82 | 20 Apr 15:32 2011
Picon

Re: In-App Billing example service lifecycle

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?

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:
>
> http://code.google.com/p/marketbilling/issues/detail?id=8
>
> The call to unbindService in Dungeons.onDestroy is a bit of a red herring:
>
> The "this" in "unbindService(this)" is BillingService.this as a
(Continue reading)

Kostya Vasilyev | 20 Apr 15:46 2011
Picon

Re: Re: In-App Billing example service lifecycle

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.
(Continue reading)

Jaisingh Gehlot | 20 Apr 15:57 2011
Picon

Re: Re: In-App Billing example service lifecycle



2011/4/20 Kostya Vasilyev <kmansoft <at> gmail.com>
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:

http://code.google.com/p/marketbilling/issues/detail?id=8

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
http://developer.android.com/guide/topics/fundamentals/bound-services...).
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
http://groups.google.com/group/android-developers?hl=en



--





JAI SINGH GEHLOT
LAB. TECHNICIAN 

--
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
http://groups.google.com/group/android-developers?hl=en
markusn82 | 21 Apr 17:00 2011
Picon

Re: In-App Billing example service lifecycle

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
themselves (afaik).

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:
>
> >>http://code.google.com/p/marketbilling/issues/detail?id=8
>
> >> 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
> >>>http://developer.android.com/guide/topics/fundamentals/bound-services...).
> >>> 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
http://groups.google.com/group/android-developers?hl=en


Gmane