Jake,
You haven't given enough information to determine if it should be called
before or after your stuff. And it also depends on what the Service
constructor does (which I don't know because I haven't looked at the source.
I guess the point I am trying to make (that it totally depends and can't be
answered as generically as you want it to be) is best illustrated with an
example:
public class Foo
{
protected int x;
public Foo()
{
x = 3;
}
}
public class Bar1 extends Foo
{
public Bar1()
{
super();
x = 5;
}
}
public class Bar2 extends Foo
{
public Bar2()
{
x = 5;
super();
}
}
In the example above, x will have the value 5 after the Bar1 constructor
finishes but Bar2 will have the value of 3 after the constructor
finishes....
So, as I said before, it completely depends on what the super class does and
what the subclass is doing. I have not looked at the source code for
Service and I don't know what your subclass does so I don't know what case
works best...
TreKing's comments are certainly valid though. From his observations it
seems that it does not matter. And if it did matter you could certainly
just try both and see which way works, as he also suggested.
Personally, I ALWAYS call super in my subclasses... Even if it is just a
placeholder hook.
Sorry that my answer was too generic. I couldn't be more specific with the
generic nature of your question.
----------------------------------------------------------------------
There are only 10 types of people in the world...
Those who know binary and those who don't.
----------------------------------------------------------------------
On Thu, Jul 15, 2010 at 2:47 PM, TreKing <[email protected]> wrote:
> On Thu, Jul 15, 2010 at 2:46 PM, Jake Colman <[email protected]> wrote:
>
>> When extending Service with your own Service, should you be calling
>> down to the super implementation of the methods that are being overridden?
>>
>
> Considering that:
> A - The sample in the documentation for Service does not and
> B - Activities explicitly require that you call up to the overridden
> functions but Service does not and
> C - I don't and everything works just lovely
>
> I would say no, you don't need to.
>
>
>> If so, do you do it before or after you've invoked your own code?
>>
>
> Try both, see what happens. Or maybe someone who's looked at the source can
> let us know what those functions do in Service, if anything. I'm assuming
> they do nothing and are there are hooks for your code.
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Beginners" group.
>
> NEW! Try asking and tagging your question on Stack Overflow at
> http://stackoverflow.com/questions/tagged/android
>
> To unsubscribe from this group, send email to
> [email protected]<android-beginners%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-beginners?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en