Android Interview Questions and Answers
With the world becoming closer and smaller and all things coming on mobile, Android has taken over all other languages for mobile application development. Android provides a complete set of a toolkit for app development. The following questions can be asked in an interview for Android.
So you have finally found your dream job in Android but are wondering how to crack the Android Interview and what could be the probable 2021 Android Interview Questions. Every interview is different and the scope of a job is different too. Keeping this in mind we have designed the most common Android Interview Questions and Answers to help you get success in your interview.
Below is the list of 2021 Android Interview Questions and Answers, which can be asked during an interview. These top interview questions are divided into two parts:
Part 1 – Android Interview Questions (Basic)
This first part covers basic Android interview questions and answers
1. What is Android? Explain the main components and what is Google Android SDK?
Answer:
Android is an open-source operating system that enables the user to develop applications on mobile devices and tablets. It is a Linux based operating system that allows the user to create and run applications on mobile with the rich high-end components it has. A user can perform all basic and advanced operations and create apps. The main components of Android are:
- Linux Kernel
- Android framework
- Android applications
- Libraries
These components enable the developer to create high-end applications that provide all the facilities in a single application with an amazing look and feel.
Google SDK is a development toolkit that is used by developers to write programs for mobile devices. It provides a graphical user interface simulating an Android-driven environment and enabling the developer to test and debug their codes.
2. What are the important items in Android and explain the importance of XML-based layouts?
Answer:
The most required items in an Android project when a project is created are as below:
a)Androidmanifest.xml
b)Build.xml
c)bin/
d)src/
e)res/
f)assets/

4.5 (9,560 ratings)
View Course
Here we have two XML files that help in providing a consistent layout. It helps in giving the developer a standard graphical definition format. Usually, all layout details are placed in these XML files and the other items are placed in source files.
Let us move to the next Android Interview Questions.
3. Explain in brief the files and folder which are created when an Android project is created?
Answer:
The new project should have the following files in the package in eclipse.
- src- This file contains java source files for the newly created project. The code for the application is to be written in this file. It should be made available under the name of a project.
- Assets- This is a folder that will contain all information regarding HTML files, text files, and databases.
- gen- This folder must have the R.java file. It is a file generated by the compiler and it references the resources that are found in the project. This file should not be modified as it is generated by the compiler.
- Android library- This folder contains an android.jar file that has all the libraries needed for creating an Android application.
- bin- It contains the .apk file that is created by ADT during the code build process. This file is the application binary file. When a developer runs his code this file has everything required to run code.
- res- This is a folder that contains all resource files used by the application. It has subfolders like drawable, menu, layout, and values, etc.
4. What is ANR? What are the precautions to be taken to avoid ANR in an application?
Answer:
This is the basic Android interview questions asked in an interview. ANR is a dialog that Android shows when an application is not responding. It stands for Application Not Responding. Usually, this state is encountered when an application is performing many tasks on the main thread and it has been unresponsive for a long period of time.
Following things can be taken into mind to avoid ANR:
1)Be careful that there are no infinite loops encountered when complex calculations are involved.
2)When a server is not responding for a long time and can result in ANR. In order to avoid this developer should define HTTP timeout for all web service and API calls.
3)A developer should use IntentService when there are many background tasks. They should be taken off the main UI thread.
4)All database and long-running network operations should be run on a different thread.
5. Write code for a Toast that will display the message “Hello, this is a Toast”.
Answer:
Toast.makeText(getApplicationContext(), “Hello, this is a Toast”,
Toast.LENGTH_LONG).show();
Part 2 – Android Interview Questions (Advanced)
Let us now have a look at the advanced Android Interview Questions.
6. Write code to generate a button dynamically?
Answer:
protected void onCreate(Bundle newInstanceState) {
super.onCreate(newInstanceState);
Button button = new Button(this);
button.setText(“Button”);
setContentView(button);
});
7. What is AIDL? What are the different data types supported by AIDL?
Answer:
AIDL stands for Android Interface Definition Language. It acts as an interface between client and service and enables the communication between them. It handles interface requirements between both of them and handles communication through interprocess communication or IPC. This involves breaking the objects into smaller parts so that Android can understand those objects. This happens because a process cannot access the memory of other processes that are running. The different data types supported by AIDL are:
- String
- Map
- List
- charSequence
- all Java data types like int, long, char, Boolean.
Let us move to the next Android Interview Questions.
8. How to handle multiple resolution screens in Android?
Answer:
Below five properties help in handling multiple screen resolutions in Android:
1)Screen size can be divided into four generalized categories like small, normal, large and extra-large
2)Similarly, screen density can also be categorized into low, medium, high and extra high.
3)When a user rotates the screen orientation device should also get changed.
4)The resolution defines the physical pixels on a screen.
5)Independent pixel provides the developer with a density-independent way to define the various layouts as per the requirement. The layouts can be customized and used accordingly.
9. Explain the process to launch an activity on an application?
Answer:
This is the advanced Android Interview Questions asked in an interview. To launch an activity developer needs to explicitly define intent. It specifies the activity that we wish to start. The following code will help you understand that activity that is sent in the second parameter in the new activity class.startActivity(). The first parameter is the Intent constructor in the current activity context.
Intent intent1= new Intent(this, SecondActivity.class);
startActivity(intent1);
If the user wishes to start activity from a particular fragment then below can be tried:
Intent intent1= new Intent(getActivity(), SecondActivity.class);
getActivity(),startActivity(intent1);
10. What are the states of an activity?
Answer:
There are four states of an activity. They are:
Active- When the activity is active in the foreground
Paused- When an activity is in the background and still visible.
Stopped- When an activity is not visible.
Destroyed- When an activity is killed or terminated.
Recommended Article
This has been a guide to the List Of Android Interview Questions and Answers. Here we have listed the top 10 Interview Questions and Answers that are commonly asked in interviews with detailed responses. You may also look at the following articles to learn more –