Google News
logo
Android Interview Questions
Android is an open-source operating system and is mainly popular for Smartphones, Tablets and Laptops.
 
This operating system is Linux Kernel-based. Using the Android operating system, the developer develops the functions or programs which can perform basic as well as the advanced type of operations on the Smartphone.
The latest version of Android OS is 12, released in October 2021. Android is a mobile operating system developed by Google. It is based on the Linux kernel and designed primarily for touchscreen mobile devices such as smartphones and tablets. Every other Android version has been named after either sweet or desserts. The following table represents the Android name, version and the year of release.

Android Name Version Year of Release
Android 1.5 Android Cupcake 2009
1.6 Donut 2009
2.0-2.1 Eclair 2009
2.2 – 2.2.3 Froyo 2010
2.3 – 2.3.7 Gingerbread 2010
3.0 – 3.2.6 Honeycomb 2011
4.0 – 4.0.4 Ice Cream Sandwich 2011
4.1 – 4.3.1 Jelly Bean 2012
4.4 – 4.4.4 KitKat 2013
5.0 – 5.1.1 Lollipop 2014
6.0 – 6.0.1 Marshmallow 2015
7.0 – 7.1.2 Nougat 2016
8.0 – 8.1 Oreo 2017
9.0 Pie 2018
10.0 Quince Tart September 3, 2019
11.0 Red Velvet Cake September 8, 2020
12.0 Snow Cone October 4, 2021
Google has changed the lives of everyone by launching a product that improves the mobile experience for everyone. Android helps in understanding your tastes and needs, by giving various features such as having wallpapers, themes, and launchers which completely change the look of your device’s interface.
 
Android has plenty of features. Some of the features are listed below :
 
* Open-source
* Customizable operating System
* Variety of apps can be developed.
* Reduces overall complexity
* Supports messaging services, web browser, storage(SQLite), connectivity,media and many more.
This is a set of tools that Android developers use in order to develop or write apps. It features a graphical user interface that emulates a handheld, Android-driven environment, making it easier for developers to create, test, and debug their code.
 
The tools include :
 
* Dalvik Debug Monitoring Services
* Android Emulator
* Android Asset Packaging Tool
* Android Debug Bridge
The build process in Android involves three steps
 
* The first step consists of the compilation of the resources folder using the Android Asset Packaging Tool (AAPT). These are compiled into a single class file known as R.java, which only holds constants.

* In the second step, the java source code needs to be compiled to .class files using javac, which are then converted to Dalvik bytecode using the ‘dx’ tool, which is one of the tools in the software development kit. The final output file is classes.ex.

* In the third and final step, the Android apkbuilder is required to take all the inputs and build the Android Packaging Key (APK) file.
List of the most popular programming languages that can be used to develop applications in Android
 
Java : Java, the most popular programming language in the world has always been a starting point for new developers and used by the majority of people who work with Android development.

Kotlin : Kotlin is a relatively new, modern, safe and object-oriented cross-platform programming language. When Android studio 3.0 was released in Oct 2017, Kotlin was announced as the official programming language for Android. Many popular applications such as Trello, Square and Corda have since then shifted to Kotlin.

C# : Using the C# language developers can build native iOS and Android mobile applications.

Python : Python has emerged as one of the most popular programming languages in recent times. A dynamic and object-oriented programming language, Python is very popular in machine learning.

Other languages that can be used in Android are C++, HTML 5.
Android Software Development Kit (SDK) and Virtual Device Manager : This tool is used to generate and handle Android Virtual Devices (AVD) and SDKs. Through the emulator in the AVD, you can specify the supported SDK version, storage in the SD card, screen resolution, and other abilities such as GPS and touch screen.

The Android Emulator : The AE is the implementation of the Android Virtual Machine, designed to run processes within a virtual device itself, which can be used on a development computer. The main use of this tool is in testing and debugging of Android applications.

Android Debug Bridge (ADB) : The ADB is a command-line debugging application doled out with the SDK. It enables developers to communicate with the device, and facilitates actions such as the installation and debugging of an application.

Android Asset Packaging Tool (AAPT) : The AAPT builds the ‘.apk’ distributable Android package file.
Android architecture refers to the different layers in the Android stack. It includes your operating system, middleware, and important applications. Each layer in the architecture provides different services to the layer just above it. The four layers in the Android stack are:
 
Android architecture is in the form of software stack components.
 
Linux Kernel : Linux Kernel is placed at the bottom of the software stack and is the foundation of the Android architecture. Using Linux kernel, Android provides a connection between the other layers of the software. It helps to develop drivers like the keypad, display, audio for device manufacture, etc.

Hardware Abstraction Layer (HAL) : HAL provides an interface between device drivers and API framework. It consists of library modules that are specific to the hardware component.

Android Runtime : Linux kernel provides a multi-tasking execution environment so that multiple processes can execute each process runs on its own instance of Android Runtime (ART). Android has core runtime libraries like Dalvik VM specific libraries, Java Interoperability Libraries, Android Libraries, and C/C++ libraries.
 
Application Framework (Java API Framework) : The entire android functionalities are available through the API. It consists of multiple services like Activity Manager, Resource Manager, Notification Manager, etc., which form the environment in which the android application runs.

Applications : The Android application is a top layer and all types of in-built applications such as SMS, Browsers, Contact, etc are included in this top layer. It also includes third-party applications that are installed by the user such as Games, etc.
Android application architecture has the following components. They are as follows :
 
Services : It will perform background functionalities
 
Intent : It will perform the inter connection between activities and the data passing mechanism
 
Resource Externalization : strings and graphics
 
Notification : light,sound,icon,notification,dialog box,and toast
 
Content Providers : It will share the data between applications
The APK file or Android application package is the compressed file format that is used to distribute and install application software and middleware onto Google’s Android operating system. The file has .apk extension and has all the application code, resource files, certificates, and other files, compressed in it.
The fragment in Android is as follows :
 
* A fragment has its own layout and behavior with its own life cycle callbacks.
* Fragments can be added or removed in an activity while the activity is running and used in multiple activities.
* Multiple fragments can be combined in a single activity to build a multi-pane UI.
* The fragment life cycle is closely related to the life cycle of its host activity which means when the activity is paused, all the fragments available in the activity will also be stopped
* Fragments were added to the Android API in the Honeycomb version of Android API version 11.
Some storage options available in Android are listed below :
 
* Shared Preferences
* Internal Storage
* External Storage
* SQLite database
Mobile app testing is the testing of applications on a device which mainly focuses on functions and features of the application.
 
Mobile Testing is the testing of the actual mobile device and focuses on mobile features like Call, SMS, Contacts, Media Player, inbuilt browsers, etc.
Android framework is a set of API’s using which the Android developers write code for the mobile apps. It contains the methods and classes to write the programming code.
 
Android framework includes a different set of tools to create image pane, text field, buttons, etc. It also includes “Activities” with which the user interacts and “Services”, which are the programs that run in the background. It is a package of different components like Intents, Broadcast Receivers, Content Providers, etc.
User navigates between different screen or app, it goes through different states in their lifecycle. So an activity lifecycle consists of 7 different methods of android.app.Activity class i.e :
 
onCreate() : In this state, the activity is created.
 
onStart() : This callback method is called when the activity becomes visible to the user.
 
onResume() : The activity is in the foreground and the user can interact with it.
 
onPause() : Activity is partially obscured by another activity. Other activity that’s in the foreground is semi-transparent.
 
onStop() : The activity is completely hidden and not visible to the user.
 
onDestroy() : Activity is destroyed and removed from the memory.
An Intent is an “intention” to do an action.  An intent is a messaging object you can use to request an action from another app component.
 
Methods are used to deliver intents to different components :
 
context.startActivity() : To start an activity
context.startService() : To start a service
context.sendBroadcast() : To deliver a broadcast
 
Types of Intent :
 
Implicit Intent : Implicit intent is when the target component is not defined in the intent and the android system has to evaluate the registered components based on the intent data.
 
Explicit Intent : Explicit intent is when an application defines the target component directly in the intent.
Activities are the part of the mobile app which the user can see and interact with.
 
For Example, if you open an SMS app which has multiple activities like create new SMS, add a contact from the address book, write the content in the SMS body, send SMS to the selected contact, etc.
 
Activity keeps a track of the following :
 
* Keeps track of what a user is currently looking for in an app.
* Keeps a track of previously used processes, so that the user can switch between ongoing process and previous process.
* It helps to kill the processes so that the user can return to their previous state

An activity is implemented as a subclass of Activity class as shown below :
 
Public class MyActivity extends Activity
{

}

 

Service is an Android component that runs in the background and acts independently. It does not provide any user interface.
 
Though the services are running behind the scene, a user can continue their work on different apps. Most of the time, the users are not aware of the services which are running in the background. These services allow the system to kill the process without interrupting the user’s ongoing work.
 
A service is implemented as a subclass of Service class :
 
Public class MainService extends Service
{

}

 

ANR stands for Application Not Responding. It is a notification or pop-up displayed by the Android platform whenever the application is performing too many functions at a time and if it is suddenly not responding for a long time to the user action.
Android supports four types of dialog boxes :
 
AlertDialog : It has a maximum of 3 buttons and sometimes AlertDialog includes checkboxes and Radio buttons to select the element.
ProgressDialog : It displays the progress bar or wheels.
TimePickerDialog : Using this dialog box, a user selects the Time.
DatePickerDialog : Using this dialog box, a user selects the Date
21 .
Android Debug Bridge (ADB) is a command-line tool that performs shell commands.
 
ADB is used for direct communication between the emulator ports. It gives direct control of the communication between the emulator instances to the developer.
Orientation is the key feature in Smartphones nowadays. It has the ability to rotate the screen between Horizontal or Vertical mode.
 
Android supports two types of screen Orientations as mentioned below :
 
Portrait : When your device is vertically aligned.
Landscape : When your device is horizontally aligned.

setOrientation() is a method using which you can set a screen alignments. HORIZONTAL and VERTICAL are two values that can be set in the setOrientation() method. Whenever there is a change in the display orientation i.e. from Horizontal to Vertical or vice versa then onCreate() method of the Activity gets fired.
 
Basically, when the orientation of the Android mobile device gets changed then the current activity gets destroyed and then the same activity is recreated in the new display orientation. Android developers define the orientation in the AndroidManifest.xml file.
In the Android platform, there are remote methods that facilitate the use of methods from one program to another. To create and implement the remote methods the first step is to define the communication interface in AIDL.
 
AIDL stands for Android Interface Definition Language. It facilitates communication between the client and the service. It also communicates the information through inter-process communication.
 
For communication between processes, the data is broken down into chunks which are easily understandable by the Android platform.
Data Types supported by AIDL are as follows :
 
* String
* List
* Map
* charSequence
* Java data types such as INT, Long, Char, Boolean, etc
Every application must have an AndroidManifest.xml file in the root directory. It contains information about your app and provides the same to the Android system.
 
The information includes the package name, Android components such as Activity, Services, Broadcast Receivers, Content Providers, etc. Every Android system must have this information before running any app code.
 
AndroidManifest.xml file performs the following tasks :
 
* It provides a name to the Java package and this name is a unique identifier for the application.
* It describes the various components of the application which include Activity, Services, Content Providers, etc. Also, it defines the classes which implement these components.
* It is responsible to protect the application and it declares the permission for accessing the protected part of the app.
* It also declares the Android API which is going to be used by the application.
* It contains the library file details which are used and linked to the application.
The four essential items are :
 
* AndroidManifest.xml
* build.xml
* bin/
* src/
* res/
* assets/
ARMv7 is a RISC(reduced instruction set computer) processor, with a Load/Store memory model. A Load/Store memory mode means memory access is restricted to specific instructions. An ARMV7 processor is a family of CPUs based on the RISC architecture developed by Advanced RISC Machines (ARM).
28 .
NDK stands for The Native Development Kit which is a set of tools. It allows you to use C and C++ code with Android. It also provides platform libraries that you can use to manage native activities and access physical device components, such as sensors and touch input.
The Android Emulator imitates Android devices on your system. Therefore, users will be able to check your application on a spread of devices and Android API levels without having to possess every physical device. The emulator provides the majority of the capabilities of a real Android device.
The major difference between onCreate() and onStart() is as follows.
 
onCreate() is called when the Activity is created; that is, it is launched or started. (Additionally, this triggers when the orientation is changed.) It is called again when the process is killed, then returned to.
 
while onStart() called following onCreate() at startup. Additionally, it is also called when the app is navigated back to after onStop() (and following onRestart()), which occurs after the Activity is no longer visible (which is during the time that "the user can see the activity on-screen, though it may not be in the foreground and interacting with the user").
Android AsyncTask going to do background operation on the background thread and update on the main thread. In android, We can't directly touch the background thread to the main thread in android development. asyncTask helps us to make communication between the background thread to the main thread.
A Handler is used to send and process Message and Runnable objects associated with a thread's MessageQueue. When a Handler created default bound with a Looper class. It will deliver messages and runnable to that Looper's message queue and execute them on Looper's thread.
 
Handlers are mainly used to Update the User Interface from a background thread, Enqueue a task for a different thread and Schedule a task for a specified time.
The onTrimMemory(int level) is used when the operating system has determined that a process to trim unneeded memory from its subprocess.
Implicit Intent is used whenever you are performing an action. For example, send email, SMS, dial number or you can use a Uri to specify the data type.

For example :
Intent i = new Intent(ACTION_VIEW,Uri.parse("https://www.freetimelearning.com")); 
startActivity(i);

 

Explicit, on the other hand, helps you to switch from one activity to another activity(often known as the target activity). It is also used to pass data using putExtra method and retrieved by other activity by getIntent().getExtras() methods.
 
For example : 
Intent i = new Intent(this, Activitytwo.class); #ActivityTwo is the target component
i.putExtra("Value1","This is ActivityTwo"); 
i.putExtra("Value2","This Value two for ActivityTwo"); 
startactivity(i);

 

* Toast notification is a message that pops up on the window.
* It only covers the expanse of space required for the message and the user’s recent activity remains visible and interactive.
* The notification automatically fades in and out and does not accept interaction events.
 
Syntax :

Toast.makeText(ProjectActivity.this, "Your message here", Toast.LENGTH_LONG).show();

AAPT is short for Android Asset Packaging Tool. This tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents.
* Broadcast Receiver is a mechanism using which host application can listen for System level events.
* Broadcast receiver is used by the application whenever they need to perform the execution based on system events. Like listening for Incoming call, sms etc.
* Broadcast receivers helps in responding to broadcast messages from other application or from the system.
* It is used to handle communication between Android operating system and applications. 

It is implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.
public class MyReceiver extends BroadcastReceiver {
  Public void onReceive(context,intent){}
}

 

WebView is a view that display web pages inside your application. According to Android, “this class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through a history, zoom in and out, perform text searches and more. In order to add WebView to your application, you have to add <WebView> element to your XML layout file.
src : contains the .java source files for your project.
gen : contains the .R file, a compiler-generated file that references all the resources found in your project.
bin : contains the Android package files .apk built by the ADT during the build process and everything else needed to run an Android application.
res/drawable-hdpi : this is a directory for drawable objects that are designed for high-density screens.
res/layout : this is a directory for files that define your app’s user interface.
res/values : this is a directory for other various XML files that contain a collection of resources, such as strings and colors definitions.
AndroidManifest.xml : this is the manifest file which describes the fundamental characteristics of the app and defines each of its components.
Activity is typically a single, focused operation that a user can perform such as dial a number, take a picture, send an email, view a map etc.
 
Fragment is a modular section of an activity, with its own lifecycle and input events, and which can be added or removed at will. Also, a fragment’s lifecycle is directly affected by its host activity’s lifecycle i.e. when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all of its fragments.
* SQLite is the open-source relational database. The SQLite engine is serverless, transactional, and self-contained. 

* Instead of the typical client-server relationship of most database management systems, the SQLite engine is integrally linked with the application. The library can also be called dynamically and makes use of simple function calls that reduce latency in database access.
DDMS stands for Dalvik Debug Monitor Server. It gives the following array of debugging features :

* Logcat
* Location data spoofing
* Network traffic tracking
* Port forwarding services
* Screen capture on the device
* Thread and heap information
* Incoming call and SMS spoofing
Low investment and better returns : Android development has a low entry barrier and is suitable for new developers looking to become proficient in the programming field.

Free SDK : One of the most prominent features of Android is that the Software Development Kit is open source and is provided free of charge, which eradicates the cost of licensing, distribution and development fee.

Easy Adoption : Android applications are scripted in Java, which is one of the most used programming languages in the world.

Reusable : Android components can be reused and even replaced by the framework.

Multi-Platform Support : The Android platform supports major OSs such as Linux, Mac OS, and Windows.

Support for Wearable Devices : The market is now flooded with wearable devices and Android has emerged as leading support for such devices that are now readily available in the market.
A nine-patch image, unlike bitmap, can be resized and used as background or other image sizes for the target device. The Nine-patch refers to the way you can resize the image : 4 corners that are unscaled, 4 edges that are scaled in 1 axis, and the middle one that can be scaled into both axes. This is what differentiates a nine-patch image from a regular bitmap.
Activity : An Activity is the screen representation of any application in Android.  Each activity has a layout file where you can place your UI.

Content Provider : Content providers share data between applications.

Service : It is a component that runs in the background to perform long-running operations without interacting with the user and it even works if application is destroyed.

Broadcast Receivers : It respond to broadcast messages from other applications or from the system itself. These messages are sometime called events or intents.
A sticky broadcast is used for communicating between applications. These broadcasts happen without the user being notified. The Android OS normally treats each application as if it were a separate user.

Here’s an example : When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
Fake Applications : There are thousands of fake apps available on the market at any given time, which when installed may try to steal your data.

Streamlining issues : There are a variety of Android devices available in the market, with different screen sizes and dimensions, but more importantly, different Android Operating Systems. Every application developer has to constantly work towards updating their application for the new OS but with various OS version and upgrades, the process is quite difficult. An application which runs smoothly on one version of the Android OS might crash on a different Android OS.

Background Processes : The abundance of running processes in the background is always an issue, as they eat up the battery quickly.
Android Runtime (ART) is an application used by the Android OS as a runtime environment. It has now replaced Dalvik, a discontinued process Virtual Machine (VM). ART translates the bytecode of the application into native instructions, which are carried out by the device’s runtime environment.
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 in the monitor of positioning and movement of the device through their high accuracy. The sensors 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.
Emulators are devices which are used to perform tasks comparable to that of real Android devices, and are used to decrease the cost of testing. But some scenarios can only be performed on real devices and not on emulators. These scenarios include :

* Bluetooth
* Messaging
* Memory related issues
* Validation of battery scenarios
* Validation of the performance
* Mounting and unmounting the memory card
Standard : This launch mode generates a new instance of the activity in the task from which it originated. It is possible to create multiple instances of the same activity, which can be added to the same or different tasks.

SingleTop : This launch mode is similar to the Standard launch mode, except if there exists a previous instance of the activity on the top of the stack, then a new instance will not be created, but the intent will be sent to the existing instance of the activity.

SingleTask : This launch mode will always create a new task and push a new instance to the task as the root one.

SingleInstance : This launch mode is the same as the SingleTask launch mode but the system doesn’t launch any new activities in the same task. In a scenario where the new activity is launched, it is launched in a separate task.
The XML based layouts help inconsistent and standard format for setting up of GUI definition format. The layout details are placed in XML files, and the other items are put in source files.
Yes, we need Android in the mobile market because it helps the users of smartphones to download applications that can provide a variety of services. The developers make various applications year after year. Android system gives them a platform from which they can display these applications to the smartphone users and find potential customers out of them. Android system offers paid and free applications for the users that could secure their data, act as a platform for information, and provide a variety of services as per the needs of the customers.
Yes, three key loops monitoring an activity. These include the following.
 
Loop 1 : Entire Lifetime : In this key loop, the activity happens between the onCreate and onDestroy.
Loop 2 : Visible Lifetime : In this key loop, the activity happens between onStart and onStop.
Loop 3 : Foreground Lifetime : In this key loop, the activity happens between onResume and onPause.
There are quite a few mobile automation testing tools that are available in the market but these are used only if the project requires it and if the application supports the automation.
 
These tools are paid as well as free tools, hence analysis needs to be done within the project team and then the appropriate mobile automation tool needs to be selected. Silk Mobile, SeeTest, Ranorex are the paid mobile automation tool while Appium, KIF, Robotium, Calabash are few free tools.
Free up memory space : There is only limited space available on mobile devices for mobile apps. To avoid crashing issues or memory-related issues, you need to first check the memory space.

Clear app data usage : You can clear the app data using the Application Manager under “Settings”. This will clear the cache memory and allow some free space to install another app or it will boost up your current app.

Memory Management : Some apps run perfectly on one type of mobile device but the same app may not work on another type of device as for such devices the processing power, memory management, and CPU speed is different. For any app to run properly on any type of mobile device, you should manage the memory on the device.

Compatibility issue : It is always not possible to test mobile apps on all mobile devices, browsers, operating systems, etc. So you need to test your mobile app on as many mobile devices as you can in order to avoid any compatibility issue.
Android Studio is using Android Device Manager (ADM), this ADM is used to detect the memory leaks in the Android platform.
 
When you open ADM in the Android Studio then on the left-hand side of the ADM, you will find your device or emulator in which a heap sign will be displayed. When you are running any mobile app then you will see the heap size, memory analysis and other statistics displayed on it.