Top Android Interview Questions & Answers

0.00 avg. rating (0% score) - 0 votes
android interview questions

Android is a mobile operating system (OS) by Google. Released under open-source license, the OS is based on the Linux kernel and is designed primarily for smartphones and tablets. It was first developed by the Android Inc., which was bought by Google in 2005. With the introduction in 2007, it became one of the most popular mobile operating systems in the world, with a huge percentage of smartphones using the OS.


As the growth of smartphone users continued and hardware technology getting updated every year, Android is also becoming more developed. The industry has a great demand for expert Android developers and is expected to increase in the coming years.


If you are looking to move into the industry, you can enroll in an Android certification course to get certified and be job-ready. Here is a comprehensive list of Android interview questions, along with their answers.


Q1. What is Android?


Ans. Android is an open-source operating system designed for mobile devices. It is a Linux based kernel that supports a large number of applications in a smartphone. It allows the developers to create and run applications that can perform both basic and advanced functions. The android app development supports Java programming language.


Q2. What is Android architecture? What are its key components?


Ans. The android architecture consists of software stacks of components that support mobile device requirements. It is made up of four components:


  • Linux Kernel
  • Libraries
  • Android Framework
  • Android Applications


Q3. Explain Android SDK?


Ans. Google software development kit (SDK) is a toolset to help developers to write apps on Android-enabled devices. Android SDK includes the following:


  • An emulator
  • Sample source code
  • Debugger
  • Tutorial for the Android OS
  • Required Libraries


Q3. What is the difference between API and SDK?


Ans. API is an interface between two applications that allows software programs to interact with each other while SDK is a set of tools that are used to develop software applications.


Q4. Explain the Android framework?


Ans. Android framework is a set of APIs used by the developers to write code for mobile applications. It already consists of methods and classes used for wringing the code.


It includes multiple tools such as text field, buttons, image pane, etc. Android framework is also a package of different components such as broadcast receivers, content providers, intents, etc.


Q5. What are the key components in the android application?


Ans. Here are the essential items required in every Android project:


  • xml
  • xml
  • bin/
  • src/
  • res/
  • assets/



Q6. What is an emulator? Explain the use of an emulator in android?


Ans. Android emulator is a software used to run and test Android applications. It is a platform used by the developers to test their application before installing it in a device. Emulators like AVD and Genymotion are used to emulate the entire operating system while the emulator like Bluestacks is used to run android applications.


Q7. What are the advantages of android?


Ans. Android is an open platform and free build on Linux. It offers the complete software stack that includes the operating system, key applications, and middleware. The demand for android app development is growing because of its robust features:


  • Multitasking
  • Diverse phone options
  • Support various technologies
  • Widgets
  • Easy adoption
  • Custom keyboards
  • Low investment and high return on investment


Q8. Differentiate between explicit Intent and implicit Intent?


Ans. Explicit intent specifies the component explicitly and passes on the target component directly in the intent.


// Currently in MainActivity


Intent intent = new Intent(this, LoginActivity.class);


startActivity(intent);


Implicit Intent doesn’t specify the component. It allows components from another app to handle the general actions.


Example: When you have to show a specific location to the user, you have to use the implicit function to request that another app will show the specified location on the map.


Q9. What are the three key loops when monitoring an activity?


Ans.  There are three key loops:


  • Entire lifetime – Activity occurs between onDestroy and onCreate
  • Visible lifetime – Activity occurs between onStop and onStart
  • Foreground lifetime – Activity occurs between onPause and onResume


Q10. Define AAPT.


Ans. Android Asset Packaging Tool (AAPT) tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents. It is used for the compilation of application resource files, i.e., XML files, AndroidManifest.xml files. It also compiles resources into binary assets. AAPT is a part of the Android SDK and helps you to see and redesign zip-perfect chronicles.


Q11. What is the APK format?


Ans. Android Package Kit (APK) is the package file format used by the Android operating system for the distribution and installation of mobile apps and middleware. APK files include all the software program codes and assets. APK is also used to compile applications before uploading to Google Play.





Q12. Differentiate between fragment and activity?


Ans. An activity is typically a single, focused operation that a user can perform. In contrast, a fragment is essentially a modular section of an activity, with its lifecycle and input events, and which can be added or removed at will.


 Q13. Explain the android fragment lifecycle?


Ans. It is used to build the dynamic user interface and make the task easy for creating a UI task for multiple screen sizes


Methods of android fragment lifecycle:


  • onAttach(): This method will be called at the initial stage before the onCreateView(). You will get this method about the activity for further initialization work.
  • onCreateView(): The system calls this method before the UI is created for the first time. The view component must be returned from the method of fragment layout.
  • onViewCreated(): This method is called after the onCreateView() method. It is particularly used when onCreateView() method is implemented.
  • onActivityCreated(): This is called after onCreateView() and onViewCreated to indicate that onCreate() activity is completed. onActivityCreated() is used to initialize work after onCreate() initialize the fragment and activity instance.
  • onStart(): This method is called once the fragment gets visible
  • onPause(): This method is called as the first indication at the time when the user is leaving the fragment. There you should perform any changes that should be persisted beyond the current user session.
  • onStop(): This method is used to stop the fragment.
  • onDestroyView(): This method is called to destroy the fragmented view.
  • onDestroy(): This method is called for the final cleanup of the fragment’s state but not guaranteed to be called don the android platform.
  • onDetach(): This method is called after onDestroy() to check whether the fragment is disassociated from its hosting activity.


Q14. What are containers?


Ans. Containers hold objects and widgets together, depending on which specific items are needed and in what particular arrangement that is wanted. Containers may hold buttons, fields, labels, or child containers.


Q15. What is the difference between Service and IntentService?


Ans. Service is the base class for Android services that can be extended to create any service.  It can be used in tasks with no UI. If you want to perform a long task, then you have to use threads within the service.


IntentService is a subclass of Service that handles asynchronous requests (expressed as “Intents”) on demand. IntentService is used in long tasks where there is no communication with the main thread, and it can use the main thread handler or broadcast intent to communicate.


Q16. What are activities?


Ans. Activities are the subclass of ContextThemeWrapper class that represents a single screen with the user interface. Android starts its program with activity by calling onCreate() callback method, same as Java, and C++ starts it with the main() function.


Example: Declaration of an activity


 <manifest … >


  <application … >


      <activity android:name=”.ExampleActivity” />


      …


  </application … >


  …


</manifest >


Q17. What are the four essential states of an activity?


Ans. Four essential states of activity are:


  • Active: If the activity is at the foreground
  • Paused: Activity is at the background and still visible
  • Stopped: Activity is not visible and hidden by the other activity
  • Destroyed: When the activity is terminated or wholly destroyed


Q18. What are Intents?


Ans. Intents display notification messages to the user from within the Android enabled device. It facilitates communication between components in multiple ways. There are two types of intent:


  • Explicit intent
  • Implicit intent


Q19. What are the components of an Android application architecture?


Ans. There are four components in android application architecture:


  • Linux kernel
  • Libraries
  • Android framework
  • Android applications


Q20. What are the three common cases of an Intent?


Ans. Common use cases for using an intent include:


  • to start an activity: Start a new instance of activity by passing an Intent to startActivity() method.
  • to start a service: Start a service to perform a one-time operation by passing an Intent to startService() method.
  • to deliver a broadcast: Deliver a broadcast by passing an Intent to sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast() method.


Q21. What are the tools placed in an Android SDK?


Ans. There are tools placed in an Android SDK:


  • Android Emulator
  • DDMS (Dalvik Debug Monitoring Services)
  • AAPT (Android Asset Packaging Tool)
  • ADB (Android Debug Bridge)


Q22. What is DDMS?


Ans. Dalvik Debug Monitor Server (DDMS) provides a wide array of debugging features. It is downloaded as a part of the Android SDK. DDMS provides some services such as on-device screen capture, on-device heap, and thread monitoring, port forwarding, and radio state information.


Q23. What is the use of an activityCreator?


Ans. An activityCreator is the first step towards the creation of a new Android project. It is a batch file and shell that will be used to create a new file system structure used for writing code in Android IDE.


Q24. What is Android Debug Bridge (ADB)?


Ans. Android Debug Bridge is a client-server program that allows developers the power to execute remote shell commands. It is a part of the Android SDK and made up of three components, i.e., a client, a daemon, and a server. It is used to support the android device and emulator.


Q25. What is the importance of settings permissions in app development?


Ans. Permissions allow certain restrictions to be imposed primarily to protect data and code. Setting permissions plays an important role in application development.


Example: If you are using WebView in your mobile phone to load a site, then you have to ask for the permission of the internet, without permission you cannot load the site.


Q26. What is AndroidManifest.xml?


Ans. AndroidManifest.xml is a resource file that is essential for the android system and contains information about the application that the Android system must know before the codes can be executed. It is called a key file that works between the android platform and android developer.


Structure of AndroidManifest.xml


<manifest>


<Elements for Application properties should come here – refer above for list>


<application>


<Elements for application components should come here – refer above for list>


</application>


</manifest>


Q27. What are the elements of AndroidManifest.xml?


Ans. There are restricted elements used by the AndroidManifest.xml file in android development:


<action>


<activity>


<activity-alias>


<application>


<category>


<data>


<grant-uri-permission>


<instrumentation>


<intent-filter>


<manifest>


<meta-data>


<permission>


<permission-group>


<permission-tree>


<provider>


<receiver>


<service>


<supports-screens>


<uses-configuration>


<uses-feature>


<uses-library>


<uses-permission>


<uses-sdk>


Q28. What is the importance of Default Resources?


Ans. Default resources are those items that are not specific to any device. It contains default strings and files that are not present, an error will occur, and the app will not run. Default Resources are organized in subdirectories of resource directory as per their resource type.


Q29. Define AIDL?


Ans. Android Interface Definition Language (AIDL) syntax is similar to Java interface, and it handles the interface requirements between a client and a service so that both can communicate at the same level through inter-process communication (IPC).


Example: Declaring an Interface


package com.marakana;


 


// Declare the interface.


interface IAdditionService {


   // You can pass values in, out, or inout.


   // Primitive datatypes (such as int, boolean, etc.) can only be passed in.


   int add(in int val1, in int val2);


}


Q30. What is a Sticky Intent?


Ans. A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it. It is a type of intent that allows the communication between the function and service.


Q31. What language is supported by Android for application development?


Ans. The official language supported by the Android application development in Java. Android application is written on, and its API is designed specially to be called by Java. Many apps on the play store are built in Java because Java is the most supported language by google.


Q32. Where and how are layouts placed in android?


Ans. Layouts are placed in the Layout folder as XML files.


Q33. What are application Widgets in android?


Ans. Widgets are miniature application views that can be embedded in other applications (such as the Home screen) and receive periodic updates. App widget host is an application component that holds other app widgets.


Example: Declaration of app widget in manifest


First, AppWidgetProvider class has to be declared in AndroidManifest.xml


<receiver android:name=”ExAppWidgetProvider” >


    <intent-filter>


        <action android:name=”android.appwidget.action.APPWIDGET_UPDATE” />


    </intent-filter>


    <meta-data android:name=”android.appwidget.provider”


               android:resource=”@xml/example_appwidget_info” />


</receiver>


Q34. What is drawable folder in android?


Ans. It is a compiled visual resource that can be used as a background, banners, icons, splash screen, etc. It is necessary to choose the appropriate size and resolution of images so that there is no possibility of an app crash. Android support some specific image formats such as GIF, JPG, BMP, PNG, and WebP. If the drawable folder is not present on your project, you can create it by:


  • First, right-click on res folder
  • Select New
  • Select Android Resource Directory
  • Name the directory as “”
  • Add Drawable to Available Qualifiers Section
  • Click ok
  • Refer Drawable resource in your XML files by calling: “@drawable/filename”


Q35. What is a ContentProvider, and what is its use?


Ans. A ContentProvider typically manages access to a structured set of data. It is responsible for encapsulating the data and ensuring data security by defining security mechanisms. It is a standard interface, connecting data to codes running in another process.


A content provider is implemented as a subclass of ContentProvider class, and it also implements the set of APIs that are used to enable other applications to execute the transactions.


public class My Application extends  ContentProvider {


}


Q36. What is ANR?


Ans. ANR is the abbreviation for Application Not Responding. If any application running on the android device and it is unresponsive for an extended period, this dialog appears to the user. Two conditions on the android device can cause ANR error:


  • If an active app does not respond within five seconds
  • Broadcast class does not finish the execution for an extended period


Q37. What is Armv7?


Ans. ARMv7 is the most common CPU architecture in Android. Its popularity is because it is evolved and optimized for more powerful computing. It is used in ARM Cortex-A, ARM Cortex-M, ARM Cortex-R CPU families.


Q38. Why can’t we run standard Java bytecode on Android?


Ans. This happens because Java and Android use a separate environment to run the code. Android uses DVM (Dalvik Virtual Machine) instead of JVM (Java Virtual Machine). Android has been modified to run on smaller devices with the exhaustion of less computer power. Java class file has to be converted into Dalvik executable files using the Android “dx” tool.


Q39. How does Activity respond when a user rotates the screen?


Ans. So, this is among the most commonly asked Android interview questions. You can reply –


When a user rotates the screen, the current Activity is ended, and a new instance of Activity is created in the new orientation, and onRestart() method is invoked. Similarly, other lifecycle methods also get invoked when Activity was first created.


Q40. What is the difference between Activity & Service?


Ans. Activity is an application component providing a screen to the user interface (UI), such as dialing the phone, clicking a photo, sending an email, or even when viewing a map. Activities work together to form a cohesive experience to the users in the email application, and each one is independent of others. An activity is implemented as the subclass of the Activity, and you can learn about it by using activities developer guide. Services are used to perform long-running background operations, and it does not have a User Interface. A service is implemented as the subclass of Service, and you can learn about services by using the Services developer guide.


Q41. What is a visible activity in Android?


Ans. A visible activity is one where the user is not interacting with the activity, but the activity is still visible, though partially. It is an important activity and cannot be killed unless it required to keep foreground activity running.


Q42. Where will you declare your activity such that the system can access it?


Ans. The activity needs to be declared in the manifest file because it provides essential information on your application on the android system.


To declare an activity, open the Manifest file and add <activity> element as the child of the <application> element


Example:


<manifest … >


<application … >


<activity android:name=”.ExActivity” />


 …


</application … >


 …


</manifest >


 


Q43. What devices have you worked on?


Ans. This is among the popular Android interview questions, as an answer to this, you may name many mobile devices available in the market having different operating systems. You can name the Android, Windows, Symbian, iPhone, etc.


Q44. What is a broadcast receiver?


Ans. The broadcast receiver is a component that responds to system-wide broadcast announcements or messages, such as “check if an internet connection is available,” download complete,” boot completed,” etc. Android runtime notifies all the registered applications after the end of the event.


The AndroidManifest.xml file can register a broadcast receiver, and it can also be registered by Context.registerReciever() method.


Q45. Why should you use only the default constructor to create a Fragment?


Ans. It is always suggested to use only the default constructor to create a Fragment because the device has to restore the state of a fragment correctly to the same state as it was in the initial state, in instances like configuration change.


Q46. What are the three key loops when monitoring an activity?


Ans. There are three loops used for the monitoring of an activity:


  • Entire lifetime – Activity occurs between onDestroy and onCreate
  • Visible lifetime – Activity occurs between onStop and onStart
  • Foreground lifetime – Activity occurs between onPause and onResume


Q47. Which dialog boxes can you use in your Android application?


Ans. Android supports four dialog boxes:


  • AlertDialog: Supports 0 – 3 buttons and a list of selectable elements
  • ProgressDialog: An extension to AlertDialog, where buttons may be added to it
  • DatePickerDialog: Used for selecting a date by the user
  • TimePickerDialog: Used for selecting time by the user


Q48. What is the difference between margin and padding?


Ans. Margin is the outer space of an element, while the padding is the inner space between content and the border.


Q49. What is the difference between RelativeLayout and LinearLayout?


Ans. In the LinearLayout, the elements are arranged either vertically or horizontally (in a row or column). Some attributes define the linear layout:


  • Weight: It specifies the difference in space in each view span relative to others. Example: In an email, you can give less weight to ‘To’ and ‘subject’ and more weight to ‘Message.’
  • Gravity: It specifies the placement of the element, whether it can be placed on top, center, or bottom.
  • Layout Gravity: It defines the placement of view itself.


In RelativeLayout, elements are arranged to correspond to the parent or other elements. The topmost view can be defined at the end of the layout and provide details to show it on the top left. Some attributes define Relative layout:


  • Position relative to the screen: Relative view can be aligned by using alignParentType, centerHorizontal, etc.
  • Position relative to other views: Other views can be aligned by using above, below, toLeftOf, etc.
  • Margins: Margins can be provided as marginTop, marginLeft, etc.


Q50. What are Adapters in Android?


Ans. An Adapter is a bridging element between an AdapterView and the underlying data for that view. It offers access to the data items and makes a View for each item in the data set.


There is some commonly used adapter in Android:


  • ArrayAdapter
  • BaseAdapter
  • Custom ArrayAdapter
  • SimpleAdapter
  • Custom SimpleAdapter


Q51. What is Orientation in Android?


Ans. It is a key feature of all smartphones. It is the feature of rotating the screen between horizontal (Landscape) and vertical (portrait) mode. The onCreate() method of the activity is fired when there is a change in screen orientation.


There are two ways to handle changes in screen orientation:


  • Anchoring Control
  • Defining layout for each mode


Example of screen orientation:


import android.app.Activity;


import android.os.Bundle;


public class ScreenOrientationAppActivity extends Activity {


    @Override


    public void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);


        setContentView(R.layout.activity_screen_orientation_app);


    }


}


Q52. What is the difference between AsyncTasks & Threads in Android?


Ans. A Thread can be triggered from any thread, main(UI), or background. It has its call stack. There are two methods by which a thread can be implemented in applications:


  • A new class is provided that extends Thread and override the run() method.
  • A new thread instance is provided with a runnable object at the time of creation.


The main thread only triggers AsyncTask. It allows performing the background task and presenting results on UI thread. AsyncTask is used at the time:


  • When small tasks have to communicate with the main thread
  • Used for tasks in parallel use multiple instances
  • Used by Dist bound tasks taht can take more than a few milliseconds


Q53. What is the difference between a regular bitmap and a nine-patch image?


Ans. A Nine-patch image allows choosing the area of an image and resizing it in the device. Images in the regular bitmap are scaled along with the height and the width in the same way.


Q54. Which method is called only once in a fragment lifecycle?


Ans. onCreate() method is fired only once during the life cycle.


Q55. Can you create an activity in Android without a user interface?


Ans. Yes, it can be created without any user interface, and these activities are treated as abstract activities.


Q56. Is it possible to change the name of an application after it is deployed?


Ans. It is possible, but not suggested. This action may break some functionality.


Q57. How will you remove widgets and icons from the Android device’s main screen?


Ans. For removing an icon or shortcut, we will press and hold that icon and then drag it downwards to the part of the screen where the remove button appears.


These are some of the popular questions asked in Android interviews. Always be prepared to answer all types of questions — technical skills, interpersonal, leadership, or methodology. If you are someone who has recently started your career in Android development, you can always get certified in one of the technical courses to get the requisite app development skills and methodologies.


Q58. How are escape characters used as attributes?


Ans. Double backslashes precede escape characters.


Example: A newline character is represented as ‘\\n.’


Q59.Name the dialog box supported by android?


Ans. Android supports four dialog boxes:


  • Alert Dialog
  • Process Dialog
  • Date Picker Dialog
  • Time Picker Dialog


Q60. What are the different states wherein a process is based?


Ans. There are four possible states:


  • foreground activity
  • visible activity
  • background activity
  • empty process



Browse Courses by Categories

About the Author

Hasibuddin Ahmed

Hasibuddin Ahmed

Hasib is a professional writer associated with learning.naukri.com. He has written a number of articles related to technology, marketing, and career on various blogs and websites. As an amateur career guru, he often imparts nuggets of knowledge related to leadership and motivation. He is also an avid reader and passionate about the beautiful game of football.