Table of contents
1.
Introduction
2.
Activity
2.1.
No Activity
2.2.
Basic Activity
2.3.
Bottom Navigation Activity
2.4.
Empty Activity
2.5.
Fullscreen Activity
2.6.
Google AdMob Ads Activity
2.7.
Google Maps Activity
2.8.
Login Activity
2.9.
Primary/Detail Flow
2.10.
Navigation Drawer Activity
2.11.
Settings Activity
2.12.
Scrolling Activity
2.13.
Tabbed Activity
2.14.
Fragment + ViewModel
2.15.
Native C++
3.
FAQs
4.
Key Takeaways  
Last Updated: Mar 27, 2024

Android Activities

Author Pradeep Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

In this blog, we will look into Android Activities. When we launch an Android app, a user interface (UI) appears on our screen. That screen is known as an Activity. We will see the different kinds of activities that can be created using Android Studio. 
In this article, we will be using the Android Studio application, so in case you haven’t yet set up the application on your system, you can check out this article.

Activity

An activity is a critical component of the android operating system. In layman’s terms, an activity is a screen with which the user interacts. This activity displays the user interface of our application. There are a lot of activities that you can create in the android studio, which are as follows:

  1. No Activity
  2. Basic Activity
  3. Bottom Navigation Activity
  4. Empty Activity
  5. Fullscreen Activity
  6. Google AdMob Ads Activity
  7. Google Maps Activity
  8. Login Activity
  9. Primary/Detail Flow
  10. Navigation Drawer Activity
  11. Settings Activity
  12. Scrolling Activity
  13. Tabbed Activity
  14. Fragment + ViewModel
  15. Native C++

                                  

No Activity

No Activity, as the name implies, means starting a new empty project. 
When you choose No Activity, no files are created automatically. Therefore, there will be no XML or Kotlin files when this activity is selected. The file structure of the project will look like this: 

Basic Activity

On selecting the Basic Activity, a new activity is created with the navigation component. It contains a menu button and a floating action button. Following files are created upon selecting a basic activity:

Bottom Navigation Activity

As the name suggests, Basic Navigation Activity creates an activity with a bottom navigation bar. You might have come across some apps that contain a navigation bar at the bottom. Instagram is one such example. Upon selecting this activity, a welcome page is created which looks something like this:

Empty Activity

Empty Activity is one of the most frequently used activities while making an android project. It creates new empty activities. The welcome page created upon selecting an Empty Activity looks something like this:

Fullscreen Activity

Upon selecting a Fullscreen Activity, a new activity is created, which toggles with the visibility of the system user interface. Many document reader apps use a full-screen activity to show slides or files in full screen for a better view. The welcome page of a fullscreen activity looks something like this:

Google AdMob Ads Activity

Google AdMob Ads Activity is used to add advertisements to the app. This is helpful when you wish to generate extra revenue for your app by using ads. There are four different ways you can attach an ad to your app, which are as follows:

  • Banner: As the name suggests, it attaches the ad as a banner to the app.
  • Native: Ads designed to fit the app
  • Rewarded Video: It is a widespread way of attaching an ad. It provides the user with some rewards for watching. This type of attachment is widely used in movie/web series streaming apps.
  • Interstitial: Full-screen ads can be attached using this method.

Using the Google AdMob Ads Activity, a new activity is created with an AdMob Ad fragment. 

Google Maps Activity

By using a Google Maps Activity, a new activity is created, which has google maps integrated into it. It can be used to track a location or show a path on the map etc. You can also customize Google Maps in your application according to your requirements.

Login Activity

Login Activity creates a new activity with a basic login/register page. It contains an Email and a password field. More fields can be added as per the requirements of your application. It is the most widely used activity, and almost every app has this activity as its first page. Upon creating a login activity, the following welcome page is created: 

Primary/Detail Flow

A Primary/Detail flow is created upon selecting a Primary/Detail Flow Activity. It is generally used to display a collection of objects with their name and details. For a tablet-sized screen, this flow is presented using two columns, but for screens with smaller sizes, only one column is used to show the collection of objects and their details. A Master Fragment and a detailed fragment are the two activities created upon selecting this template. 

Navigation Drawer Activity

This Activity can be used to create a sliding left menu, which can be used to display essential navigation links of the application. It is highly convenient while navigating from one link to another in the app. To use a Navigation Drawer Activity, the user generally needs to slide the screen from left to right or click on a floating action button.

Settings Activity

As the name suggests, the Settings Activity creates a basic layout for the settings of an application. Almost all smartphone devices have a settings application on the mobile. 

Scrolling Activity

While reading a lengthy document on the device, sometimes you need to scroll a bit to read the rest of the file’s content. A Scrolling Activity creates a new activity with a scrolling feature which is highly useful in a such a case. It provides a vertical scrolling feature to the application.

Tabbed Activity

It is used to create an activity with tabs. Tabs are displayed horizontally, and upon clicking on a particular tab, users can move from one tab to another. This type of activity is quite common in social media applications. You might have used the Whatsapp app; the main page where tabs for chats, status, and calls are displayed is one example of this activity. 

Fragment + ViewModel

Upon selecting the Fragment + ViewModel activity, a new activity is created with a fragment and a view model. A fragment provides an activity with a more modular design. It is used to encapsulate functionality, making it easier to resue withing different activities. View model basically serves as a connecting link between the View and the Model.

Native C++

Native C++ creates a project with an empty activity that is configured to use JNI(Java Native Interface). JNI describes a way for the Java/Kotlin Executed code to interact with the native code written in C/C++. 

FAQs

  1. What is the difference between a No Activity and an Empty Activity?
    No Activity creates a new project with no files, but an Empty Activity creates a new project with an empty activity that contains a basic layout file.
     
  2. What is a Model?
    A Model handles the abstraction of the data layer. To save and fetch the data, Model and ViewModel work together. 
     
  3. What is the purpose of View?
    A View layer informs the ViewModel about the action of the user. It doesn’t contain any application logic; it just observes the behavior of ViewModel.

Key Takeaways  

Cheers if you reached here!!!

In this blog, we learned about Activity in Android. We discussed what an activity is and the different kinds of activities you can create using Android Studio. After reading this blog, I believe you will be able to work with Android Activities smoothly.

Now that you have learned how to create different kinds of activities in Android Studio, you might want to write your first Hello World program in the language; check out our other article on Android Basic Hello World App. And to learn in-depth about android development, check out our Android Development course on the Coding Ninjas website.

Live masterclass