Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Extends Application and Extends Activity in Android?

Tags:

java

android

I am confused as to the difference between the two. In my application I have just used Extends Activity and the application is working perfectly, so what is the purpose of Extends Application?.

Would you use it on the first class you create in the Android application?

Thanks.

like image 438
jcrowson Avatar asked Apr 06 '10 21:04

jcrowson


People also ask

What is the difference between activity and AppCompatActivity?

Activity is the basic one. Based on Activity , FragmentActivity provides the ability to use Fragment . Based on FragmentActivity , AppCompatActivity provides features to ActionBar .

What does extends application mean in Java?

Definition and Usage The extends keyword extends a class (indicates that a class is inherited from another class). In Java, it is possible to inherit attributes and methods from one class to another. We group the "inheritance concept" into two categories: subclass (child) - the class that inherits from another class.

What is extend in Android?

Extensions provide a means of associating additional attributes with users or public keys and for managing a certification hierarchy. The extension format also allows communities to define private extensions to carry information unique to those communities.

What is an application class in Android?

The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.


1 Answers

The android.app.Application class is an optional facility for extending and storing application-global state. There are other ways of doing this, so most apps don't customize this class.

Activities however are what defines every major stage of your application. It wouldn't be possible to build an application without Activities. You will have a main Activity class and this will indeed be defined with 'extends Activity'.

like image 134
Jim Blackler Avatar answered Oct 11 '22 13:10

Jim Blackler