Android Interview Questions And Answers


For almost 15 years, Android, a Linux-based operating system, has been the number one mobile operating system. You can find android operating systems on virtually any phone and tablet all over the globe. There are also other operating systems in the market, some of them, such as Chrome OS and Windows 11, support android applications.

In 2004, the American technology company Android Inc. started to make an operating system for smartphones. In 2005, the American search engine company Google Inc. saw the future for this project and bought Android Inc.

For android interview questions, you must know the basics of Android Architecture. The Android operating system contains a stack of software components which you can divide into five sections and four main layers.

Software Components

Linux kernel: Android has a powerful Linux kernel. It supports various hardware drivers and manages input and output requests. It is the heart of the operating system as it provides basic system functionalities like process management, memory management, and device management.

Libraries: The software also contains a set of libraries and open-source web browsers to play and record audio and video. Moreover, it also provides an SQLite database for storing and sharing application data.

Android runtime: By Android runtime, you get the main component known as Dalvik Virtual Machine. The Dalvik VM is responsible for running apps on android devices and executing the files in the .dex format.

Application Framework: The application framework layer is essential as it provides many higher-level services to applications such as view system, package manager, resource manager, and more. The developers can use these services in their applications.

Unique Features

Nowadays, many other devices like TV, cars, and watches use a specialized user interface feature of Android. Some other unique features that a person must know to excel in Android interview questions are as below:

  • Autocorrect and Dictionary: Android operating system comes with an auto-correction feature. Therefore, whenever you misspell any word, it will provide you with meaningful and correct suggestions that match the comments in its Dictionary.
  • Voice-based: You can use voice actions for different purposes, such as calling, texting, navigation, etc.
  • Multitasking: With the help of special handling of memory allocation, a user can multitask.
  • Screen capture: Smartphones with Android software provide the facility if you want to capture your device’s screen by pressing some buttons simultaneously.
  • TV recording: In the smart Android TV, there is a feature that will capture ongoing video. It can also replay it as per the user’s request.
  • Multiple language support: Android can support different languages.
  • Connectivity: Android supports connectivity via GSM/EDGE, Bluetooth, LTE, CDMA, EV-DO, UMTS, NFC, IDEN and WiMAX. 

1 . What is Android and the latest version of Android ?

Android is an operating system that is built basically for Mobile phones. It is based on the Linux Kernel and other open-source software and is developed by Google. It is used for touchscreen mobile devices such as smartphones and tablets. But nowadays these are used in Android Auto cars, TV, watches, cameras, etc. It has been one of the best-selling OS for smartphones. Android OS was developed by Android Inc.

The latest version of Android is Android 14 and the initial stable release date is August, 2022.

2 . What’s Activity in Android ?

Activity class is one of the very important parts of the Android component. Any app, no matter how small it is (in terms of code and scalability), has at least one Activity class. Unlike most programming languages, in which the main() method is the entry point for that program or application to start its execution, the android operating system initiates the code in an Activity instance by invoking specific callback methods that correspond to specific stages of its lifecycle. So it can be said that An activity is the entry point for interacting with the user.

3 . Why is XML used for frontend development in Android ?

XML stands for Extensible Markup Language which is a markup language much like HTML used to describe data. XML itself is well readable both by humans and machines. Also, it is scalable and simple to develop. In Android, we use XML for designing our layouts because XML is a lightweight language, so it doesn’t make our layout heavy.

4 . What are the components of the Android Application ?

There are some necessary building blocks that an Android application consists of. These loosely coupled components are bound by the application manifest file which contains the description of each component and how they interact. The four main components of android applications are:

  • Activities
  • Services
  • Content Providers
  • Broadcast Receiver
  • Intents

5 . What is the Dalvik Virtual Machine ?

DVM is a virtual machine to execute Android applications. The Java bytecode(.class file) generated by the javac compiler is converted into Dalvik bytecode to make the application source files executable on the DVM. Since Android devices have a definite processing capacity, memory, and battery life, the DVM design principle aims to optimize itself so that it can load fastly and run smoothly even on low memory/powered devices. This virtual machine is very efficient in running multiple instances on the same device.

6 . What are the differences between Dalvik and ART ?

DALVIK VIRTUAL MACHINEANDROID RUN TIME
Faster Booting timeRebooting is significantly longer
Cache builds up overtimeThe cache is built during the first boot
Occupies less space due to JITConsumes a lot of storage space internally due to AOT
Works best for small storage devicesWorks best for Large storage devices
Stable and tested virtual machineExperimental and new – not much app support comparatively
Longer app loading timeExtremely Faster and smoother Faster and app loading time and lower processor usage
Uses JIT compiler(JIT: Just-In-Time)Thereby resulting in lower storage space consumptionUses AOT compiler(Ahead-Of-Time) thereby compiling apps when installed
Application lagging due to garbage collector pauses and JITReduced application lagging and better user experience
App installation time is comparatively lower as the compilation is performed laterApp installation time is longer as compilation is done during installation
DVM converts bytecode every time you launch a specific app.ART converts it just once at the time of app installation. That makes CPU execution easier. Improved battery life due to faster execution.

7 . How Does an Android App Work ?

Developing an android application involves several processes that happen sequentially. After writing the source code files, when developers click the Run button on the Android studio, plenty of operations and processes start at the backend.

  • Building the APK File
    • Code Compilation
    • Conversion into Dalvik bytecodes
    • Generating .apk file
    • App Distribution
  • Deploy the Application
    • Establish the ADB Server
    • Transfer .apk file to the Device
  • Run the Application
    • App launch request
    • Conversion of the .dex code to native OAT format

8 . What is Toast in Android ?

A Toast is a short alert message shown on the Android screen for a short interval of time. Android Toast is a short popup notification that is used to display information when we perform any operation in our app. It disappears automatically. If the user wants a permanently visible message, then a notification can be used.

9 . What’s Service in android ?

Services are a special component that facilitates an application to run in the background in order to perform long-running operation tasks. The prime aim of a service is to ensure that the application remains active in the background so that the user can operate multiple applications at the same time. A user interface is not desirable for android services as it is designed to operate long-running processes without any user intervention. A service can run continuously in the background even if the application is closed or the user switches to another application.

10 . What’s Content Provider ?

In Android, Content Providers are a very important component that serves the purpose of a relational database to store the data of applications. The role of the content provider in the android system is like a central repository in which data of the applications are stored, and it facilitates other applications to securely access and modify that data based on the user requirements.  The system allows the content provider to store the application data in several ways. Users can manage to store the application data like images, audio, videos, and personal contact information by storing them in SQLite Database, in files, or even on a network.

11 . What’s Broadcast Receiver ?

Broadcast in android is the system-wide event that can occur when the device starts, when a message is received on the device, when incoming calls are received, or when a device goes to airplane mode, etc. Broadcast Receivers are used to respond to these system-wide events. Broadcast Receivers allow us to register for the system and application events, and when that event happens, then the registered receivers get notified. There are mainly two types of Broadcast Receivers:

  • Static Broadcast Receivers: These types of Receivers are declared in the manifest file and work even if the app is closed.
  • Dynamic Broadcast Receivers: These types of receivers work only if the app is active or minimized.

12 . What’s Gradle and write down its usage ?

Gradle is a build system (open source) that is used to automate building, testing, deployment, etc. “Build.gradle” are scripts where one can automate the tasks. For example, the simple task to copy some files from one directory to another can be performed by Gradle build script before the actual build process happens. 

Usage: Every Android project needs a Gradle for generating an apk from the .java and .xml files in the project. Simply put, a Gradle takes all the source files (java and XML) and applies appropriate tools, e.g., converts the java files into dex files and compresses all of them into a single file known as apk that is actually used.

13 . What’s Fragment in android ?

In Android, the fragment is the part of Activity that represents a portion of the User Interface(UI) on the screen. It is the modular section of the android activity that is very helpful in creating UI designs that are flexible in nature and auto-adjustable based on the device screen size. There are mainly 3 types of fragments:

  • Single Fragment
  • List Fragment
  • Fragment Transaction

14 . What’s  RecyclerView in Android & How it works ?

RecyclerView is a ViewGroup added to the Android Studio as a successor of the GridView and ListView. It is an improvement on both of them. It has been created to make possible construction of any lists with XML layouts as an item that can be customized vastly while improving the efficiency of ListViews and GridViews. This improvement is achieved by recycling the views which are out of the visibility of the user. For example, if a user scrolled down to a position where items 4 and 5 are visible; items 1, 2, and 3 would be cleared from the memory to reduce memory consumption.

15 . Describe Folder, File & Description of Android Applications.

The following are brief explanations of these concepts:

  • gen: gen contains the compiler-generated .R file which references all the resources in the project
  • src: src holds the .java source files in our project
  • bin: bin contains the .apk file built by the ADT during the build process, along with all the other things needed to run an Android application
  • AndroidManifest.xml: This file is the manifest file that explains the basic features of the application and defines all its components
  • res/values: res/values is a directory for other various XML files that contain resources such as strings, color definitions and more
  • res/drawable-hdpi: This is a directory for objects that are drawable and designed for high-density screens
  • res/layout: It is a directory of files that define the UI for your application

16 . What’s the Difference Between Intent and Intent filters?

An Intent is an object passed to Context.startActivity(), Context.startService() or Activity.startActivityForResult() etc. to launch an activity or get an existing activity to do something new. On the other hand, an Intent filter describes the capability of the component(like activities, services, and broadcast receivers).

17 . What is the AndroidManifest.xml?

Every project in Android includes a manifest file, which is AndroidManifest.xml, stored in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements. This file includes nodes for each of the Activities, Services, Content Providers, and Broadcast Receivers that make the application and using Intent Filters and Permissions determines how they coordinate with each other and other applications. The manifest file also specifies the application metadata, which includes its icon, version number, themes, etc., and additional top-level nodes can specify any required permissions, unit tests, and define hardware, screen, or platform requirements.

18 . What is the difference between a Fragment and an Activity?

ActivityFragment
Activity is an application component that gives a user interface where the user can interact. The fragment is only part of an activity, it basically contributes its UI to that activity.
Activity is not dependent on fragment Fragment is dependent on activity. It can’t exist independently.
we need to mention all activity it in the manifest.xml file Fragment is not required to mention in  the manifest file
We can’t create multi-screen UI without using fragment in an activity,After using multiple fragments in a single activity, we can create a multi-screen UI.
Activity can exist without a Fragment  Fragment cannot be used without an Activity.
Creating a project using only Activity then it’s difficult to manageWhile Using fragments in the project, the project structure will be good and we can handle it easily.
Lifecycle methods are hosted by the OS. The activity has its own life cycle.Lifecycle methods in fragments are hosted by hosting the activity.
Activity is not light weight. The fragment is the lite weight.

19 . What’s Context in Android?

The context in Android can be understood as something which gives us the context of the current state of our application. We can break the context and its use into three major points: 

  • It allows us to access resources.
  • It allows us to interact with other Android components by sending messages.
  • It gives you information about your app environment.

There are mainly two types of context available in Android. 

  1. Application Context and
  2. Activity Context

20 . Top Image Loading Libraries in Android.

  • Picasso
  • Glide
  • Fresco
  • COIL (Coroutine Image Loader)
  • UIL (Universal Image Loader)

21 . Define the architecture of Android.

The Android architecture consists of five components. These are:

  • Linux Kernel: The Linux Kernel forms the basis of the Android platform, and this powers features such as memory and power management, and various drivers. It serves as an abstraction layer before the other layers.
  • Platform Libraries: Android’s platform libraries are native C and C++ libraries that provide support for graphics and media, and a WebKit library. This allows developers to implement graphic functionality and display web content, among other things.
  • Android Runtime: Android Runtime (ART) and the core libraries are among the most significant parts of the architecture. It serves as the foundation for the application framework, and has features like optimized garbage collection.
  • Android applications: This is what you see when you use your phone, and is the top level of the architecture. Core apps like email, SMS, and contacts come pre-installed.
  • Application Framework: The application framework contains classes that are used in the creation of an application. They provide the building blocks with which you can create apps, and provide services such as a resource manager, notification manager, and activity manager.

22 . Explain the term ANR.

The term ANR is short for Application Not Responding. It is displayed as a notification by the Android OS every time the application stops responding to the user’s action for a considerable amount of time.

23 . Explain the dialog boxes supported on Android.

Android supports four dialog boxes:

  • AlertDialog: AlertDialog supports 0-3 buttons, along with a list of selectable items, such as radio buttons and checkboxes
  • DatePickerDialog: Used for the selection of date by the user
  • TimePickerDIalog: Used for the selection of time by the user
  • ProgressDialog: Used to display a progress bar and is an extension of the AlertDialog. It also supports the addition of buttons.

24 . What are Android Frameworks?

Android frameworks are a set of APIs that make the development process easier. Developers can write apps quickly because APIs provide tools like intents, text fields, and more. It is essentially a software tool kit that allows for quick construction of the skeleton of an application.

25 . What is View in Android?

The view is a class that represents the basic building block for UI components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. It is a superclass for all the UI components. The most common UI components are:

  • TextView
  • EditText
  • ImageView
  • Button
  • ProgressBar
  • CheckBox, etc.

26 . Difference Between View and ViewGroup in Android

  View                                                      ViewGroup
View is a simple rectangle box that responds to the user’s actions.ViewGroup is the invisible container. It holds View and ViewGroup
View is the SuperClass of All component like TextView, EditText, ListView, etcViewGroup is a collection of Views(TextView, EditText, ListView, etc..), somewhat like a container.
A View object is a component of the user interface (UI) like a button or a text box, and it’s also called a widget.A ViewGroup object is a layout, that is, a container of other ViewGroup objects (layouts) and View objects (widgets)
Examples are EditText, Button, CheckBox, etc.For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also.
View refers to the android.view.View classViewGroup refers to the android.view.ViewGroup class
android.view.View which is the base class of all UI classes.ViewGroup is the base class for Layouts.

27 . What is Kotlin Coroutine on Android?

The Kotlin team defines coroutines as “lightweight threads”. They are sort of tasks that the actual threads can execute. Kotlin coroutines introduce a new style of concurrency that can be used on Android to simplify async code. The official documentation says that coroutines are lightweight threads. By lightweight, it means that creating coroutines doesn’t allocate new threads. Instead, they use predefined thread pools and smart scheduling for the purpose of which task to execute next and which tasks later.

28 . How do you find memory leaks in an application on the Android platform?

The Android Device Manager (ADM) helps find memory leaks in an application on Android. When you open ADM in Android Studio, you can see parameters such as heap size and memory analysis along with many others while you run an application.

29 . How Garbage Collector Works in Android?

Garbage Collector in Android has no compacting. This means the address of objects in the heap never changed after their creation. So garbage collection can be triggered when an allocation fails when an

  • OutOfMemoryError is about to be triggered,
  • When the size of the heap hits some soft limit, and
  • When a GC was explicitly requested.

30 . What is an “Emulator”?

An “Emulator” in Android helps the developers play around with an interface that acts as a real mobile device. This way, it becomes easier for the developers to write and test different codes for the application. The process of debugging also becomes possible through emulators. Thus, emulators provide a safe platform for testing codes in their early phases as well as in the later stage when the bugs need to be dealt with.

31 . What is an Activitycreator?

An Activitycreator is an initial step towards the creation of the Android project. It consists of the shell script that can be used for creating a new file system that is necessary for writing codes within the Android system.

32 . What are Sensors in Android?

Android-based devices have an assortment of built-in sensors in them, which measure certain parameters such as motion, orientation, and more. These sensors help to monitor the positioning and movement of the device with high accuracy. They can be both software and hardware-based on nature. The three prominent categories of sensors in Android devices are:

  • Position Sensor: It is used to measure the physical position of the Android device. This includes orientation sensors and magnetometers
  • Motion Sensors: These sensors include gravity, rotational activity, and acceleration sensors which measure the rotation of the device or the acceleration and much more.
  • Environmental Sensor: It includes sensors that measure temperature, pressure, humidity, and other environmental factors

33 . What’s Android SDK and its Components?

Android SDK stands for Android Software Development Kit which is developed by Google for Android Platform. With the help of Android SDK, we can create Android Apps easily. Android SDK is a collection of libraries and Software Development tools that are essential for Developing Android Applications. Whenever Google releases a new version or update of Android Software, a corresponding SDK also releases with it. In the updated or new version of SDK, some more features are included which are not present in the previous version. Android SDK consists of some tools which are very essential for the development of Android Application. These tools provide a smooth flow of the development process from developing and debugging. Android SDK is compatible with all operating systems such as Windows, Linux, macOS, etc.

Components:

  • Android SDK Build tool.
  • Android Emulator.
  • Android SDK Platform-tools.
  • Android SDK Tools.

34 . Disadvantages of Android

  • some drawbacks, where the development team needs time to adjust with the various screen sizes of mobile smartphones that are now available in the market and invoke the particular features in the application.
  • The Android devices might vary broadly. So the testing of the application becomes more difficult.
  • As the development and testing consume more time, the cost of the application may increase, depending on the application’s complexity and features.

35 . What’s a sticky intent?

This is a broadcast using the send sticky broadcast() method. The intent sticks around after the broadcast, which allows others to collect data from it.

36 . What’s the difference between mobile testing and mobile application testing?

Mobile Testing is performed on the mobile device itself, specifically on the device’s features like Contacts, SMS, the browsers, and its Calling function. Mobile Application Testing tests the features and functions of the apps loaded onto a mobile device.

37 . What’s a “bundle” in Android?

Bundles are used to pass the required data to sub-folders.

38 . What is AAPT?

This is an acronym for Android Asset Packaging Tool. The tool gives developers the ability to deal with zip-compatible archives, including content viewing, creation, and extraction.

39 . What is ADB?

This acronym stands for Android Debug Bridge (a tool found in SDK). It’s a command-line tool used to communicate between the emulator instances.

40 . What are containers?

Containers, as the name itself implies, holds objects and widgets together, depending on which specific items are needed and in what particular arrangement that is wanted. Containers may hold labels, fields, buttons, or even child containers, as examples.

41 . What is Orientation?

Orientation, which can be set using setOrientation(), dictates if the LinearLayout is represented as a row or as a column. Values are set as either HORIZONTAL or VERTICAL.

42 . Enumerate the three key loops when monitoring an activity

  • Entire lifetime – activity happens between onCreate and onDestroy
  • Visible lifetime – activity happens between onStart and onStop
  • Foreground lifetime – activity happens between onResume and onPause

43 . When is the onStop() method invoked?

A call to onStop method happens when an activity is no longer visible to the user, either because another activity has taken over or if in front of that activity.

44 . What role does Dalvik play in Android development?

Dalvik serves as a virtual machine, and it is where every Android application runs. Through Dalvik, a device is able to execute multiple virtual machines efficiently through better memory management.

45 . What is the importance of Default Resources?

When default resources, which contain default strings and files, are not present, an error will occur and the app will not run. Resources are placed in specially named subdirectories under the project res/ directory.

46 . When dealing with multiple resources, which one takes precedence?

Assuming that all of these multiple resources are able to match the configuration of a device, the ‘locale’ qualifier almost always takes the highest precedence over the others.

47 . What is AIDL?

AIDL, or Android Interface Definition Language, handles the interface requirements between a client and a service so both can communicate at the same level through interprocess communication or IPC. This process involves breaking down objects into primitives that Android can understand. This part is required simply because a process cannot access the memory of the other process.

48 . What’s LiveData in Android Architecture Component and its Advantages?

LiveData component is an observable data holder class i.e, the contained value can be observed. LiveData is a lifecycle-aware component and thus it performs its functions according to the lifecycle state of other application components. Further, if the observer’s lifecycle state is active i.e., either STARTED or RESUMED, only then LiveData updates the app component. LiveData always checks the observer’s state before making any update to ensure that the observer must be active to receive it. If the observer’s lifecycle state is destroyed, LiveData is capable of removing it, and thus it avoids memory leaks. It makes the task of data synchronization easier.

Advantages of LiveData component:

  • UI is updated as per the appropriate change in the data
  • It removes the stopped or destroyed activities which reduce the chance of app crash
  • No memory leaks as LiveData is a lifecycle-aware component.

49 . What’s Android KTX?

KTX library is the only one among the foundation components which was introduced for the first time with the release of the Jetpack. Android KTX is a collection of Kotlin extensions that are designed to facilitate developers to remove boilerplate code as well as to write concise code while developing android applications with Kotlin language. Here KTX in the name stands for Kotlin Extensions. Below is an example of a piece of code without using and after using the Android KTX library:

Code snippet of SQLite without using KTX library:

db.beginTransaction()
try {
// insert data
db.setTransactionSuccessful()
}  
finally {
db.endTransaction()
}
Above code after using KTX library:
db.transaction {
   // insert data
}

50 . What is ViewModel in Android ?

ViewModel is one of the most critical classes of the Android Jetpack Architecture Component that support data for UI components. Its purpose is to hold and manage the UI-related data. Moreover, its main function is to maintain the integrity and allows data to be serviced during configuration changes like screen rotations. Any kind of configuration change in Android devices tends to recreate the whole activity of the application. It means the data will be lost if it has not been saved and restored properly from the activity which was destroyed. To avoid these issues, it is recommended to store all UI data in the ViewModel instead of an activity.