I've derived a class from IntentService
and I'm wondering if it is necessary to call through the super class onCreate
and onDestroy
methods when overriding these methods in my implementation as it happens when you override such methods in an Activity
.. If it is necessary, do these invocation need to be the first thing we do in the overriding method? In the Activity
documentation they are very clear about that, while in the Service
or IntentService
docs I can't find anything specific.
I'm wondering if it is necessary to call through the super class onCreate and onDestroy methods when overriding these methods in my implementation as it happens when you override such methods in an Activity.
Absolutely. Those methods are implemented on IntentService
; if you fail to call through to them, your service simply will not work.
If it is necessary, do these invocation need to be the first thing we do in the overriding method?
I would recommend calling super.onCreate()
as the first thing that you do in your implementation of onCreate()
, and calling super.onDestroy()
as the last thing that you do in your implementation of onDestroy()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With