The number of smartphone users is expected to grow from 1.5 billion in 2014 to around 2.5 billion in 2019 according to Statista.com. The same report states that Android, with 80 percent of all smartphones sales, leads the global smartphone market. With these numbers only expected to rise in the coming years, Android app development has emerged as one of the hottest career options today!
While both iOS and Android skills are in high demand, employers are hiring Android developers much faster and more often than any other professionals in mobile tech, according to Mashable.com. The demand for Android developers is on a meteoric rise and the time is right to break into a career in Android development. To help you get started, we have compiled a list of frequently asked Android interview questions to help you ace the Android interviews that come your way. In case you have attended Android interviews yourself or have any questions that you want us to answer for you, do feel free to add them as comments below.
Android Interview Questions:
1. What is an Android Framework?
Android Framework is an essential part of the Android Architecture. It is a set of APIs that allows developers to write apps and has the following components:
|Services||Components that conduct long-running operations in the background, without the inclusion of a user interface.|
|Intent||Objects that initiate actions from other app components, either within your program (explicit intents) or through another piece of software on the device (implicit intents).|
|Activities||Components that provide users with screens on which they can interact with objects and perform actions. This is the base from which Intents can be deployed.|
|Content Providers||Components that enable users to access data within an app such as audio, video, images, contact information etc.|
|Others||App widgets and Processes and Threads|
2. What is the Android Architecture?
Android architecture refers to the different layers in the Android stack. The four layers in the Android stack are:
- Linux Kernel
- Android Framework
- Android Applications
You can find more information about Android layers, stack and their functions in this blog post.
3. What is the difference between File, Class and Activity in android?
The difference between them are as follows:
- File is a block of arbitrary information or resources for storing information. It can be any file type.
- Class is a compiled from of .Java file which Android uses to produce an executable apk.
- Activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type but just a class that can be extended in Android to load UI elements on view.
4. What is APK format?
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.
5. What is Google Android SDK?
The Google Android SDK is a tool set that provides a developer the API libraries and tools required to build, test, and debug apps for Android in Windows, Mac or Linux.
6. What is an ANR? How can ANR be prevented?
ANR stands for ‘Application Not Responding’. This dialogue is displayed if the main thread in the application has been unresponsive for a long time and in the following conditions:
- When there is no response to an input event after 5 seconds.
- When a broadcast receiver is not done executing within 10 seconds.
One technique is to create a child thread to prevent the Android system from concluding a code that has been unresponsive for a long period of time. Most of the actual workings of the codes can be placed within the child thread to ensure that the main thread runs with minimal unresponsive time.
7. How do you launch an activity in your application?
An activity can be launched by creating an explicit intent that defines the activity that we want to launch. In the below code snippet, the first parameter to Intent constructor is the current activity context and the second parameter is the new activity class. startActivity() method can be called on Activity context.
Intent intent = new Intent(this, SecondActivity.class);
8. What is the use of WebView in Android?
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.
9. What are the different kinds of context in Android?
Context defines the current state of an App. Context provides access to creating new activity instance, access databases, start a service, etc. There is a base class ApplicationContext, and sub classes for components: Activity, Service.
10. What are the different storage methods in Android
Android offers several options to save persistent application data. They are:
- Shared Preferences – Store private primitive data in key-value pairs.
- Internal Storage – Store private data on the device memory
- External Storage – Store public data on the shared external storage
- SQLite Databases – Store structured data in a private database.
11. What are the tools required to develop Android Apps?
The tools required are:
- Eclipse + ADT plugin
- SDK Tools
You can also use Android Studio by Google.
12. What is Intent?
An Intent is an “intention” to do an action.
According to Android, “An Intent is a messaging object you can use to request an action from another app component.” There are three use cases for Intent:
- To start an activity
- To start a service
- To deliver a broadcast
There are two types of Intent in Android:
- Implicit Intent
- Explicit Intent
13. What is a Sticky Intent?
A Sticky Intent is a broadcast from sendStickyBroadcast() method which floats around even after the broadcast, allowing others to collect data from it.
14. Explain Folder, File & Description of Android Apps
- 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.
15. How to ‘Start Another Activity’?
Intent i = new Intent(getApplicationContext(), Activity2.class); startActivity(i);
16. What is AAPT?
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.
17. What are containers?
Containers, holds objects and widgets together, depending on which specific items are needed and in what particular arrangement that is wanted. Containers may hold labels, fields, buttons, or even child containers.
18. What are some of the disadvantages of Android?
Android being an open-source platform, and considering that different Android operating systems have been released on different mobile devices, there’s no clear cut policy to how applications can adapt with various OS versions and upgrades. An app that runs on one version of Android OS may or may not run on another version.
Another disadvantage is that it can be challenging for developers to create apps that can adjust correctly to the right screen size and other varying features and specs of various Android devices.
19. Name the four essential states of an activity
The four essential states of an activity are:
- Active – if the activity is at the foreground
- Paused – if the activity is at the background and still visible
- Stopped – if the activity is not visible and therefore is hidden or obscured by another activity
- Destroyed – when the activity process is killed or completed terminated
20. What is the difference between a regular bitmap and a nine-patch image?
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.
21. Which language is supported by Android for application development?
The main language that is supported for Android app development is Java programming language. Java is the most popular language for app development, which makes it ideal even for new Android developers to quickly learn to create and deploy applications in the Android environment.
22. What are the dialog boxes that are supported in Android?
Android supports four dialog boxes:
- AlertDialog: An alert dialog box supports zero to three 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.
23. Give an example for sticky broadcast.
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.
24. What is DDMS?
DDMS stands for Dalvik Debug Monitor Server. It gives the following array of debugging features:
- Port forwarding services
- Screen capture
- Thread and heap information
- Network traffic tracking
- Location data spoofing
25. Name some exceptions in android?
- Inflate Exception
Got a question for us? Please mention it in the comments section and we will get back to you.