Last updated Jan. 4, 2019
Our Android interview questions and answers collection is all about different types of questions that can be used in an interview, in order for the employer to test your skills and knowledge.
In the following sections we will discuss about Android OS regarding its functionality, Command line tools, Performance and other topics.
Here are some Android related interview questions and their respective answers.
Table Of Contents
A.General Questions about Android
1. What is Android?
Android is a stack of software for mobile devices which includes an Operating System, middle-ware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine. Many Virtual Machines run efficiently by a DVM device. DVM executes Java languages byte code which later transforms into .dex format files.
2. What are the advantages of Android?
- Highly Customizable and Versatile
- Easy Installation and Compatibility
- Highly optimized Virtual Machine – DVM (Dalvik Virtual Machine)
3. Does android support other languages than java?
- Xamarin (C#)
- Corona (LUA)
- Rhodes (Ruby)
4. What is the difference between SDK and NDK?
- NDK is a toolset that lets you embed components that make use of native code in your Android applications.That means you have to write portion of code in C/C++ just to achieve the speed.
- SDK (software development kit) is a set of development tools used to develop applications for Android platform. Applications are written using java and run on Dalvik. That means it will be slower than what you could achieve with C/C++.
5. What is the APK format?
The APK file is compressed AndroidManifest.xml file with extension .apk. It also includes the application code (.dex files), resource files, and other files which are compressed into a single .apk file.
6. What is a Handler typically used for?
Handler is used for two main reasons:
- to schedule messages and runnables to be executed at some point in the future
- to enqueue an action to be performed on a different thread than your own
7. Can an application be started on powerup?
Yes when given permission in AndroidManifest.xml file.
8. What is a resource?
Resources are user defined XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.
9. How to Translate in Android?
The Google translator translates the data of one language into another language by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens.
10. What is the AndroidManifest.xml?
Every app project must have an AndroidManifest.xml file (with precisely that name) at the root of the project source set. The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.
11. What is Context?
Context is an entity (Interface in a general sense, in Java more like an abstract class) that represents various environment data. It provides access to local files, databases, etc.
12. What is an Activity?
Activity is an application component which is presented to the user as a single window.
13. Explain Activity life cycle briefly.
There are seven different methods in an Activity Life-Cycle:
- onCreate(), is called when activity is first created.
- onStart(), is called if the activity becomes visible to the user.
- onResume(), is called if the activity starts to interact with the user.
- onPause(), is called if the activity is expected to resume shortly.
- onStop(), is called if the activity is no longer visible to the user.
- onRestart(), is called If the activity comes back from the stopped state.
- onDestroy(), is called If the activity is finished running.
Android system invokes these callbacks to know whether the state has been changed.
14. Define the three key loops when monitoring an activity
- Entire lifetime – activity begins between the first call onCreate() through to a single final call to onDestroy()
- Visible lifetime – activity begins between onStart() and before the onStop() method has not been called.
- Foreground lifetime – activity begins after a call onResume() and before the onPause() call.
15. Which types of flags are used to run an application on Android?
Following are two types of flags to run an application in Android:
- FLAG_ACTIVITY_NEW_TASK – If it’s already running in a task, then that task is brought to the foreground else the activity creates a new task.
- FLAG_ACTIVITY_SINGLE_TOP – If the activity is currently at the top of the stack then the activity will not be launched.
- FLAG_ACTIVITY_CLEAR_TOP – If the activity is already running in the current task, then this activity is brought to the top of the stack and all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.
16. Differentiate Activities from Services
- Activities are GUIs and can terminated by the user.
- Services can run independently in the background.
17. What is fragment and how it differs from an activity?
A fragment is a reusable part of an activity which can be combined with other fragments in a single activity.
18. What is the difference between Serializable and Parcelable?
- Serializable is a standard Java interface which is easy to implement but causes a bit of garbage collection.
- Parcelable is faster than Serializable because it is optimized for Android.
19. Define Android Architecture
There are 4 components in android architecture:
- Linux Kernel
- Libraries – (Android Runtime)
- Android Framework
- Android Applications
20. Define the Android Application Architecture
Android Application Architecture has the following components:
- Services like Network Operation
- Intent – To perform inter-communication between activities or services
- Resource Externalization – such as strings and graphics
- Notification signaling users – light, sound, icon, notification, dialog etc.
- Content Providers – They share data between applications
21. What are the main components in an Android Application?
There are four different component types:
- Broadcast receivers
- Content providers
D.Intents and Intent Filters
22. What is an Intent?
A class (Intent) which describes what a caller desires to do. The caller will send this intent to Android’s intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and the Adobe Reader apps will be the perfect activity for that intent (class).
23. What’s the difference between an implicit and an explicit intent?
There are two types of intents:
- Implicit Intents call system components and declare a general action to perform.
- Explicit Intents invoke an activity class or service to start a component.
24. What is the function of an intent filter?
Intent filters are used to filter out intents that components are willing to receive. If a component has any intent filter it can receive both implicit and explicit intent if not it can receive explicit intent.
E.User Interface and Navigation
25. What is an Adapter?
Adapter acts as a bridge between an AdapterView and the underlying data for that view.
26. What are the major difference between ListView and RecyclerView?
RecyclerView (advanced and flexible version of ListView):
- Easy animations
- Contains ViewHolder by default
- Supports horizontal, grid and staggered layouts
- Supports Header and footer
- Supports OnItemClickListner
- Easy to add a divider
- Inbuilt arrayAdapter
27. What is the process of creating custom Views?
- Extend an existing View class or subclass with your own class.
- Override some of the methods from the superclass.
- Use your new extension class.
28. What is needed to make a multiple choice list with a custom view for each row?
Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1?. That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.
29. What dialog boxes are supported in android?Android supports 4 dialog boxes:
- AlertDialog: An alert dialog box supports 0 to 3 buttons and a list of selectable elements, including check boxes and radio buttons. Among the other dialog boxes, the most suggested dialog box is the alert dialog box.
- ProgressDialog: This dialog box displays a progress wheel or a progress bar. It is an extension of AlertDialog and supports adding buttons.
- DatePickerDialog: This dialog box is used for selecting a date by the user.
- TimePickerDialog: This dialog box is used for selecting time by the user.
30. What are Toasts?
A toast provides simple feedback about an operation in a small popup. It only fills the amount of space required for the message and the current activity remains visible and interactive. Toasts automatically disappear after a timeout.
31 What is FrameLayout?
FrameLayout is designed to block out an area on the screen to display a single item.
F.Images and graphics
32. How the nine-patch Image different from a regular bitmap?
It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device.
33. What is the difference between nine-patch Image vs regular Bitmap Image?
The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.
34. What is a Service?
Service is an Android component which runs in the background and acts independently. It does not provide any user interface.
35. What is a Broadcast Receiver?
36. What is a ThreadPool?
A ThreadPool can run multiple parallel instances of a task, so you should ensure that your code is thread-safe. Enclose variables that can be accessed by more than one thread in a synchronized block. This approach will prevent one thread from reading the variable while another is writing to it.
37. What is AIDL?
Android Interface Definition Language (AIDL), handles the interface requirement between a client and a service using interprocess communication (IPC).
38. What data types are supported by AIDL?
AIDL has support for the following data types:
- Java primitive types (int, char, boolean…)
39. How is a bounded service created through AIDL?
- Create the .aidl file
- Implement the interface
- Expose the interface
H.App data and files
40. What are the different data storage options available on the Android platform?
Your data storage options are the following:
- Internal Storage – store private data on the device file system.
- External Storage – store public data on the shared external file system.
- Databases (SQLite) – store structured data in a private database.
- Shared Preferences – store private primitive data in key-value pairs.
41. What are Content Providers?
Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications.
I.Command line tools
42. What is AAPT2?
Android Asset Packaging Tool (AAPT2) parses, indexes, and compiles the resources into a binary format that is optimized for the Android platform.
43. What is ADB?
ADB stands for Android Debug Bridge.is a command line tool which allows developers to performs shell commands.Its basic function is to control the communication towards and from the emulator port.
44. What is ANR?
ANR stands for Application Not Responding. It is a dialog(notification or pop-up) that appears to the user if the application is unresponsive.
45. When does ANR occur?
An ANR will be triggered for your app when one of the following conditions occur:
- While your activity, which is in the foreground, has not responded to an input event within 5 seconds.
- While your activity, which is not in the foreground, has not finished executing within a considerable amount of time.
Want more Android interview questions?
subscribe to our newsletter
So, what other Android interview questions are there? Let us know in the comments and we will include them in the article!