Monday , November 29 2021

What is Activity in Android Studio – The Basic Fundamentals

What is Activity in Android Studio – The Basic Fundamentals – Activity is a User Interface (UI) concept that usually represents a single screen of an Android application.

What is Activity in Android Studio – The Basic Fundamentals

This user interface screen can have one or more views as per the requirement, but views are not compulsory. That is, there can also be an Android App that does not have any View in its activity.

We can consider an activity as a part of our Android App that helps the user to perform an action. In simple words, Activity is the medium in the form of User Interface which handles various Actions that are performed due to User interactions.

For example, when a user taps a button that appears on a screen in an Android App, the Task that is performed in the Response of that Tapping Action is specified and implemented in this Activity Part.

Suppose we want the Android App to close when a user clicks a button.

To meet this need, the Button Click Action Response in Close Programming Codes (Program Logics) is written under Activity, which is a Java Class.

Because each activity of the Android App is a Java Class File whose action is performed by the User Interface of the Layout View File linked to this Java Class File by the Program Codes, it is handled by the Linked Activity Class File itself.

Tasks related to data viewing, creating data and editing data are usually completed under an activity. In other words, CRUID (Create, Read, Update, Insert, Delete) operations are performed only in the Activity Class file of Android App.

Activity is a Compulsory Part of any Android App, and the first Screen Display that occurs when you open any Android App is the activity itself. Also, the User Interface related to each Activity is either Specifically Compulsory as Hard Code or it is created as a Separate XML File named View, which is Associate with Activity. .

In simple words, no activity can happen without a User Interface. Then, whether the User Interface is in the form of a Separate XML File named View, or the User Interface is hard coded in the Activity Class itself.

Also, as we said earlier, any Android App can have one or more activity, but all Activities have an activity that is the Entry Point of that Android App, and only one such activity in an Android App May be, which is commonly referred to as Launcher Activity or Main Activity. This is the activity that first appears on the screen as soon as that Android App starts.

Every activity of any Android App also has a fixed Life Cycle, about which we will learn in detail further.

Activity is basically a Java Class File. Therefore, if we wish, we can write various program logics related to creating User Interface as Hard Code in this class file.

What is Activity in Android Studio – The Basic Fundamentals

But usually an Android App is developed as an application based on the MVC pattern, under which Activity plays the role of a Controller, while the User Interface is defined as View.

As a result, due to the MVC pattern, we are able to follow the rule of Separation of Concerns, due to which it is possible to keep the Program Logic related to the Actions of the App, Separate from the Visual Logic related to the User Interface, and develop, Modify, Extend and It becomes easy to manage.

See Also – Android App Architecture Components | Android Developers

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *