UMAR-MOBITSOLUTIONS
UMAR-MOBITSOLUTIONS

Reputation: 78004

What is the Usage of Android Super Class?

friends,

any one guide me what is the purpose of Super class in android i have seen in many @Override methods. for example

@Override
        protected void onProgressUpdate(final Object... args) 
         {   super.onProgressUpdate(args);
}

@Override
        protected void onPostExecute(Boolean result) {
            super.onPostExecute(result);
}

@Override     
        protected void onPreExecute() {
            super.onPreExecute();
}

any help would be appreciated.

Upvotes: 10

Views: 17503

Answers (3)

Nisse
Nisse

Reputation: 4717

The superclass of a class is the class that the class was extended from, or null if it wasn't extended.

for example, say you have a class called object, containing an onDestroy() method. If you then make a class based on object, called textbox, that extends(inherits) object, and thus has all the methods found in object. If you have no onDestroy() specifically for textbox, the onDestroy() inherited from object would get called, if you create your own onDestroy() to override the one from object that one will be called instead.

To make sure you are not missing important functionality that should come with textbox being an object, such as correct memory management when destroying the class, it's important to also do what would be done for an object, not only what you want to do for your textbox, this is done by calling the super.onDestroy(), which in this case would essentially call object.onDestroy().

Upvotes: 4

underwood
underwood

Reputation: 278

Using the Keyword super

Briefly: if you override some method (onProgressUpdate,..) in your class but want to use original one from parent class you use super keyword.

I recommend you using super as in example to prevent breaking parent class logic.

Upvotes: 7

Sunil Pandey
Sunil Pandey

Reputation: 7102

in super class many hardware interaction, memory management codes are written which are necessary for performing these function so if you override any method then u can write your own codes and let the other complexity handles by super class of android

Upvotes: 2

Related Questions