Activity base class?
What is Activi开发者_如何学Cty base class: java.lang.Object or android.content.Context?
The class overview is not clear to me (see the image please).
In Java every class has an Object
as a superclass (You can also have more information here). Context
is a Java class hence it has Object
at the root of its inheritance tree hierarchy. Context
is a class that holds information about an application environment as described in the official documentation, and Activity
has it in its inheritance tree.
Context is the base class for Activity.
I was confuse the about the base class of an android, Is Object is the base class or Activity is the base class??? but i studied and found the solution.
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.
Activity Tree Hierarchy
My Activity
↓extends
AppCompatActivity
↓extends
FragmentActivity
↓extends
ComponentActivity
↓extends
androidx.core.app.ComponentActivity
↓extends
Activity
↓extends
ContextThemeWrapper
↓extends
ContextWrapper
↓extends
Context
(This is base abstract Base Class)
精彩评论