Top Android Interview Questions and Answers in 2021
The Android mobile Operating System developed by Google was initially released in 2008, and saw its latest release in August 2018, with 9.0 ‘Pie’. The Android OS is the most popular mobile OS in the world, with over 75% market share (Source: Stats Counter).
As the popularity of Android is soaring by the second, Android developers are in demand.
Top Android Interview Questions and Answers
Here we bring to you 50 top Android interview questions and answers that will make you interview-ready.
Basic Level Interview Questions
Question: Explain the build process in Android?
Answer: 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.
Question: List some languages that can be used to program in Android
Answer: Below is a 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.
Question: What are the different tools available in Android development? Explain their functions.
Answer: There are a variety of tools available to help Android developers:
- 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.
Question: Explain the Android Interface Definition Language.
Answer: Android Interface Definition Language or AIDL facilitates the communication between the client and service. For the procedure of communication between processes, the data is split into small portions which are easily recognized by the Android platform.
Question: Describe Folder, File & Description of Android Applications
- 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 .apkk 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
Question: What are ‘activities’? Describe the lifecycle of an activity.
Answer: Activities in Android are containers/windows to the UI. The lifecycle of an activity is as follows
- OnCreate(): Here, the views are created and data is collected from bundles.
- OnStart(): It is called if the activity is visible to the user. It may be succeeded by onResume() if the activity reaches the foreground and onStop() if it converts into hidden.
- OnResume(): It is called when the activity starts an interaction with the user.
- OnPause(): This is called when the activity is going to the background but hasn’t been killed yet.
- OnStop(): This is called when you are no longer visible to the user.
- OnDestroy(): Called when the activity is finishing
- OnRestart(): Called after the activity has been stopped, prior to it being started again
Question: State some advantages of Android.
Answer: Below are some advantages of Android:
- 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.
Question: What is Android Runtime?
Answer: 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.
Question: Explain the dialog boxes supported on Android.
Answer: Android supports four dialog boxes
- AlertDialog: The most suggested dialog box, the 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.
Question: What are some of the disadvantages of Android?
Answer: Below are some disadvantages of the Android Operating System
- 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.
Intermediate Level Interview Questions
Question: Explain Sensors in Android
Answer: 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.
Question: Name some testing scenarios which be tested on real devices and not on emulators.
Answer: 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:
- Mounting and unmounting the memory card
- Validation of battery scenarios
- Memory related issues
- Validation of the performance
Question: What is Context?
Answer: The Context in Android, as its name suggests, in the context of the current state of your application or object. The context comes with services such as giving access to databases and preferences, resolving resources and much more. There are two types of context:
- Activity Context: This context is attached to the lifecycle of an activity. It should be used when you are passing the context in the scope of an activity or you need the context whose lifecycle is attached to the current context.
- Application Context: This context is attached to the lifecycle of an application. The application context can be used where you need a context whose lifecycle is separate from the current context or when you are passing a context beyond the scope of activity.
Question: How do you find memory leaks in an application on the Android platform?
Answer: To find memory leaks in an application on Android, the Android Device Manager (ADM) is used by the Android Studio. 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.
Question: State the architecture of an Android application.
Answer: Any Android application has the following components:
- Notification- Features such as light, sound, icons and more
- Services- To perform background functionalities
- Intent- To perform inter-connection between activities and mechanisms that pass on data
- Resource Externalization- Features such as strings and graphics
- Content Providers- To share data between applications
Question: If an application is crashing frequently, how will you troubleshoot it?
Answer: If an Android application is crashing frequently, you can do the following:
- Free Memory: As there is a limited amount of space on mobile devices, you can try by freeing up memory space for the application to function properly.
- Compatibility Check: It may not be a hardware problem, but more of a software issue. It is not always possible to test an application for all devices and OS system. There might be a chance that the application is not compatible with your OS. Check the compatibility on the application’s Google Play Store page.
- Memory Management: Some applications run perfectly on one mobile device but may crash on other devices. This is where processing power, memory management and CPU speed comes into play. Check the application memory requirements if application is constantly crashing.
- App Data Usage: If an application is crashing frequently, you can delete the application’s data, which will clear its cache memory and allow some free space on your device and might boost the app’s performance.
Question: Explain DDMS in brief.
Answer: The Dalvik Debug Monitor Server (DDMS) is a debugging tool in Android Studio. It has a wide range of debugging features, such as:
- Port forwarding
- Location data spoofing
- Screen capture
- Radio state information
- Thread and Heap information
The DDMS tool is now deprecated and Android now suggests the users use Android Profiler instead.
Question: Explain the difference between implicit and explicit intent.
Answer: Below is the difference between the two intents
- Explicit Intent: An explicit intent is where you inform the system about which activity or system component it should use to generate a response to this intent.
- Implicit Intent: An implicit intent allows you to declare the action you wish to carry out, after which the Android system will check which components are registered to handle that specific action.
Question: What is the AndroidManifest.xml file and why do you need this?
Answer: The AndroidManifest.xml file contains information about the application, which is then provided to the Android system. This data may include the package name, components such as activity, services, content providers and more. This file executes the following tasks:
- Providing a unique name to the Java package
- Describing various components of the application, such as activity, services and more. It also defines the classes which will implement these components
- Declaring the Android API which will be used by the application
- Contains the library file details linked to the application
Question: Explain different launch modes in Android
Answer: Below are the different launch modes in Android
- 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.
Advanced Level Interview Questions
Question: State the components which are necessary for a New Android Project
Answer: When a new Android project is created, the following components are required:
- Manifest: Contains the xml file
- Build/: Contains build output
- Res/: Contains non-code resources such as bitmap images, UI strings and more
- Src/: Contains the code and resources
- Assets/: Contains a file which can be converted into an .apk file
Question: What is the importance of setting up permission in Android application development?
Answer: If the code is accessible to anyone and without restrictions, there may be a scenario where the code is compromised, resulting in defect leakage. Once the permissions are set, the code becomes available to authorized users only.
Question: Explain the term ANR in Android
Answer: 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 action for a considerable amount of time.
Question: What are the different data types supported by AIDL?
Answer: AIDL or Android Interface Definition Language facilitates the communication between the client and service. Data Types supported by AIDL are as follows:
- INT, Long, Char, Boolean (Java data types)
Question: Name the different data storage options available on the Android platform.
Answer: Android platform provides a variety of data storage options which can be used depending upon the need of the user. The storage options are:
- SharedPreference: This option stores data in XML files.
- SQLite: This stores structured data in the private database
- Internal Storage: This stores data in the device file system where it cannot be read by other applications
- External Storage: This stores data in the file system but it can be accessed to all apps in the device
Question: What is an Android System?
Answer: An Android System is an open-source operating system. It is developed to be used on smartphones and tablets. Android System is based on the Linux Kernel system, which offers the developers to create and run applications that can perform essential as well as advanced functions.
Question: Define the architecture of Android?
Answer: The Android architecture consists of four components. These are:
- Linux Kernel.
- Android applications.
- Android Framework.
Question: What is the full form of AAPT? Explain AAPT?
Answer: The full form of AAPT is Android Asset Packaging Tool. This tool is used by developers that offer them the ability to deal with the zip-compatible archives. Hence the process of creation, extraction, and viewing of the contents easier with this tool in application.
Question: What is an “Emulator” in Android?
Answer: An "Emulator" in android helps the developers to play around 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. Hence, 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.
Question: What is an Activitycreator?
Answer: 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.
Question: What are the activities in Android?
Answer: The activities are referred to as a window to the user interface. It helps in the display of output or could even ask for inputs so that the dialog boxes and other roles can be performed to create a user interface.
Question: What are intents in Android system?
Answer: Intents in Android system displays the notification messages to the users from an Android enabled device such as smartphone, tablet, etc. This way, attempts are made to alert the user, and respond can be expected as per the intents.
Question: Is there any difference between activities and services?
Answer: Yes, there are a lot of differences between activities and services. These differences are stated as under:
|These are closed||These are open|
|These can be terminated at any time||These cannot be terminated at any time|
|They are designed to run before the scenes||These are designed to run behind the scenes|
|They are dependent||They act independently|
|They are not continuous||They are not continuous|
Question: What is the use of XML based layouts?
Answer: 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.
Question: Define containers in the Android system?
Answer: The containers in the Android system helps in holding objects and widgets together so that the specific items and arrangements can be fulfilled. These containers include labels, buttons, fields, etc.
Question: Do we need Android in the mobile market?
Answer: 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.
Question: Is there any disadvantage to the Android System? List them all.
Answer: Yes, there are several disadvantages to the Android system. These are listed below.
- There is no policy on how the application can be adapted with the operating system versions and upgrades on smartphones.
- Not all applications can run on every kind of operating system of smartphones. Thus the download could cause loss of data, time, and download facility.
- Some of the applications in the Android system may not fit the screen of all kinds of smartphones.
- Android system offers such applications as well, which tends to collect user data. This may cause leaking of vital personal information data from smartphone users.
- Android system could offer download application which may not be backed by credible sources and could cause harm to the mobile device.
Question: What is the full form of ADB? Define ADB?
Answer: The full form of ADB is Android Debug Bridge. ADB helps the developers in creating remote shell commands. The main function of ADB is to allow and control the communication process towards emulator port and later getting a response from it.
Question: What are the states in an activity?
Answer: There are four states in an activity. These include the following.
- Active state: In this state, the activity is in the foreground.
- Paused state: In this state, the activity is in the background and visible.
- Stopped state: in this state, the activity is at the background but no visible or even hidden or obscure other activities.
- Destroyed state: In this state, the activity is completely terminated or killed or removed.
Question: What is the full form of ANR? Define ANR?
Answer: The full form of ANR is Application Not Responding. ANR is a dialogue that appears on the screen of the application user on its electronic device. It seems when the application is unresponsive for a more extended period.
Question: What are the permissions in the application development process?
Answer: The permissions in the application development process include restrictions that are imposed to protect the data and code. These permissions are applied to protect the application from getting compromised, attacked by viruses, steal away users' information, and to cause bug defects.
Question: What are the intent filters?
Answer: The intent filters are the vital components of the Android system because it helps in responding, filtering, and receiving the right information inputs.
Question: Are there any critical loops while monitoring an activity?
Answer: 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.
Question: What are the possible states in which a process is based?
Answer: The possible states in which a process is based include the following.
- State 1: Foreground activity
- State 2: Visible activity
- State 3: Background activity
- State 4: Empty activity
Question: Can we prevent ANR in the Android system?
Answer: Yes, we can prevent ANR in the Android system. ANR hinders the Android system from concluding a code that has been responsive for a long time. The prevention can be made by creating a child thread wherein most of the actual workings of the codes can be applied, and the minimum period unresponsive times can be revealed.
Question: What is Dalvik? How is it useful to Android System?
Answer: Dalvik is a virtual machine that helps the Android system is running its applications. It helps the smartphones and other electronic devices to download the applications from the virtual machines which have every application stored in its memory. The new applications, their removal, and updates are all made in the Dalvik platform.
Question: What are the Default Resources? How are they useful?
Answer: The Default resources include the default strings and files. Their absence will result in creating errors on the screen and could also hinder the running of the downloaded application. They are useful as they are placed as subdirectories under the project directory, which supports the running of the downloaded application.
Question: Define AIDL?
Answer: AIDL stands for Android Interface Definition Language. AIDL is used for handling the interface requirements that exist between the client and the service provider. It acts as a platform to communicate at the same level through the interprocess communication or IPC method. The steps followed in AIDL includes breaking down the objectives into primitives so that the Android system can understand them well. AIDL also helps in limiting the applications from fetching information from other devices.
Question: What is a Fragment in the Android system?
Answer: A Fragment in the Android system is a part of the activity, which is modular in a sense. They can move around and could even combine with other fragments to form a single activity. Fragments are reusable.
So this was a list of the 50 Top Android interview questions and answers. Do you have any other questions that we left unanswered? Let us know via the comments below. Also, don’t forget to check our best Android tutorials recommended by the community.
Need more challenging preparation, then try this comprehensive udemy course: 190+ Android Interview Questions.
If you prefer books, then you must have a look at this interview book which will help you prepare for an upcoming interview: Java: Programming Basics for Absolute Beginners (Step-By-Step Java Book 1).
People are also Reading:
- How to Become a Mobile App Developer?
- Top Java Interview Questions & Answers
- Kotlin vs Java: Difference you should Know
- JQuery Interview Questions
- Node.JS interview Questions
- Top Data Structure Interview Questions
- Top Bootstrap Interview Questions and Answers
- AWS Interview Questions & Answers
- Best Data Science Interview Questions & Answers
- HCL Recruitment Process or Interview Questions & Answers