What is an Activity? Which method is implemented by all subclasses of an Activity?
What is an Activity? Which method is implemented by all subclasses of an Activity?
Answer
An Activity is the screen representation of an application in Android.
It serves as an entry point for the user’s interaction. Each activity has a layout file where you can place your UI. An application can have different activities. For example, facebook start page where you enter your email/phone and password to login acts as an activity.
Below are the two methods which almost all subclasses of Activity will implement:
onCreate(Bundle): It is a method where your initialization is done. Under this, you will callsetContentView(int) with a layout resource which defines your UI. Also, you can retrieve the widgets in that UI by using findViewById(Int). These are required to interact programmatically.
onPause(): It is a method which deals with the user whenever it leaves the activity. So any changes made by the user should be commited which is done by the ContentProvider that holds the data.
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website