Android Interview Questions for Fresher and Experienced.
What is Android?
Android is a stack of software for mobile devices which includes an Operating System, middleware 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.
What are the advantages of Android?
It is simple and powerful SDK.
Licensing, Distribution or Development fee is not required.
Easy to Import third party Java library.
Supporting platforms are – Linux, Mac Os, Windows.
Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.
Components can be reused and replaced by the application framework.
Optimized DVM for mobile devices.
SQLite enables to store the data in a structured manner.
Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies.
The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.
The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.
Describe 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
How will you record a phone call in Android? How to get a handle on Audio Stream for a call in Android?
Permissions.PROCESS_OUTGOING_CALLS: Allows an application to monitor, modify, or abort outgoing calls.
What is activity?
The building block of the user interface is the activity. They're in a long-running conversation with the user and may remain active, even when idle, as long as the conversation continues. In terms of desktop development, an Activity is equivalent to a Form.
Describe the APK format.
The (Android Packaging Key) APK file is compressed format of the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.
What are the different phases of the Activity life cycle?
As an activity transitions from state to state, it is notified of the change by calls to the following protected methods:
1) void onCreate(Bundle savedInstanceState)
2) void onStart()
3) void onRestart()
4) void onResume()
5) void onPause()
6) void onStop()
7) void onDestroy()
Taken together, these seven methods define the entire lifecycle of an activity.
What is intent?
A class (Intent) describes what a caller desires to do. The caller sends this intent to Android’s intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF file is an intent, and the Adobe Reader is the suitable activity for this intent.
What is an Explicit Intent?
In an explicit intent, we actually specify the activity that is required to respond to the intent. In other words, we explicitly designate the target component. This is typically used for application internal messages.
What is an Implicit Intent?
In an implicit intent, the main power of the android design, we just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, we do not declare the target component and hence is typically used for activating components of other applications seamlessly
What is an AndroidManifest file?
Applications declare their components in a manifest file that's bundled into the Android package, the .apk file that also holds the application's code, files, and resources. The manifest is a structured XML file and is always named AndroidManifest.xml for all applications. It is also used for naming any libraries the application needs to be linked against (besides the default Android library) and identifying any permission the application expects to be granted.
What language does Android support for application development?
Android applications are written using the Java programming language.
What's the difference between a file, a class and an activity in android?
- It is a block of arbitrary information, or resource for storing information. It can be of any type.
- Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk
- An activity is the equivalent of a Frame/Window in GUI toolkits. It is not a file or a file type it is just a class that can be extended in Android for loading UI elements on view.
What is the significance of the .dex files?
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically, translating compiled applications written in the Java programming language.
What does ADT stand for?
ADT stands for Android Development Tools
The Android SDK includes several tools and utilities to help you create, test, and debug your projects.
What are the different tools in Android? Explain them?
The Android SDK and Virtual Device Manager-
It is used to create and manage Android Virtual Devices (AVD) and SDK packages. The AVD hosts an emulator running a particular build of Android, letting you specify the supported SDK version, screen resolution, amount of SD card storage available, and available hardware capabilities (such as touch screens and GPS).
The Android Emulator-
An implementation of the Android virtual machine designed to run within a virtual device on your development computer. Use the emulator to test and debug your Android applications.
Dalvik Debug Monitoring Service (DDMS) -
Use the DDMS perspective to monitor and control the Dalvik virtual machines on which you're debugging your applications.
Android Asset Packaging Tool (AAPT) -
Constructs the distributable Android package files (.apk).
Android Debug Bridge,(adb) -
Android Debug Bridge, is a command-line debugging application shipped with the SDK. It provides tools to browse the device, copy tools on the device, and forward ports for debugging.
What is Dalvik Virtual Machine?
The name of Android's virtual machine. The Dalvik VM is an interpreter-only virtual machine that executes files in the Dalvik Executable (.dex) format, a format that is optimized for efficient storage and memory-mappable execution. The virtual machine is register-based, and it can run classes compiled by a Java language compiler that have been transformed into its native format using the included "dx" tool. The VM runs on top of Posix-compliant operating systems, which it relies on for underlying functionality (such as threading and low level memory management). The Dalvik core class library is intended to provide a familiar development base for those used to programming with Java Standard Edition, but it is geared specifically to the needs of a small mobile device.
What is Android Runtime?
Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.
What is the Open Handset Alliance?
The OHA is a consortium of 84 technology and mobile companies that have joined hands to accelerate innovation in mobile technology and at the same time offer the end users a better, cost-effective and richer mobile experience. Members of this include Google, HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas Instruments, Samsung, LG, T-Mobile, Nvidia. The OHA was started on 5 November 2007 by Google and 34 other companies. Android is the main software of the alliance.
What is ViewGroup?
A ViewGroup is a special view that can contain other views (called children.) The view group is the base class for layouts and views containers. This class also defines the class ViewGroup.LayoutParams which serves as the base class for layouts parameters.
What is a Service?
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Services run without a dedicated GUI, but, like Activities and Broadcast Receivers, they still execute in the main thread of the application's process. A Service could be, facility for an application to expose some of its functionality to other applications.
What is the difference between Service and Thread?
Service is like an Activity but has no interface. Probably if you want to fetch the weather for example you won't create a blank activity for it, for this you will use a Service. It is also known as Background Service because it performs tasks in background. A Thread is a concurrent unit of execution. You need to know that you cannot update UI from a Thread. You need to use a Handler for this.
What is a Content Provider?
Content Providers are the only way to share data across Android applications. They store and retrieve data thus making it accessible to all. Content Providers give a uniform interface to access the data. Android platform provides default implementations of content providers for data types like audio, video, images, contact information etc.
What is a Toast Notification?
A toast notification is a message that pops up on the surface of the window. It only fills the amount of space required for the message and the user's current activity remains visible and interactive. The notification automatically fades in and out, and does not accept interaction events.
What are the other Notifications?
A Status Bar Notification:
It is used for persistent reminders that come from the background and request the user's response.
A Dialog Notification:
It is Used for Activity-related notifications.
Experienced Level Questions
What is the importance of XML-based layouts?
The use of XML-based layouts provides a consistent and somewhat standard means of setting GUI definition format. In common practice, layout details are placed in XML files while other items are placed in source files.
What are containers?
Containers, as the name itself implies, 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, as examples.
) What is Orientation?
Orientation, which can be set using setOrientation(), dictates if the LinearLayout is represented as a row or as a column. Values are set as either HORIZONTAL or VERTICAL.
What do you think are some disadvantages of Android?
Given that Android is an open-source platform, and the fact 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. One app that runs on this particular version of Android OS may or may not run on another version. Another disadvantage is that since mobile devices such as phones and tabs come in different sizes and forms, it poses a challenge for developers to create apps that can adjust correctly to the right screen size and other varying features and specs.
What is adb?
Adb is short for Android Debug Bridge.
It allows developers the power to execute remote shell commands. Its basic function is to allow and control communication towards and from the emulator port.
What are the four essential states of an activity?
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.
What is ANR?
ANR is short for Application Not Responding
. This is actually a dialog that appears to the user whenever an application have been unresponsive for a long period of time.
Which elements can occur only once and must be present?
Among the different elements, the and elements must be present and can occur only once. The rest are optional, and can occur as many times as needed.
How are escape characters used as attribute?
Escape characters are preceded by double backslashes. For example, a newline character is created using ‘\\n’
What is the importance of settings permissions in app development?
Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting to defects in functionality.
Is there a case wherein other qualifiers in multiple resources take precedence over locale?
Yes, there are actually instances wherein some qualifiers can take precedence over locale. There are two known exceptions, which are the MCC (mobile country code) and MNC (mobile network code) qualifiers.
What is the proper way of setting up an Android-powered device for app development?
The following are steps to be followed prior to actual application development in an Android-powered device:
-Declare your application as “debuggable” in your Android Manifest.
Turn on “USB Debugging” on your device.
Set up your system to detect your device.
What are the steps in creating a bounded service through AIDL.
1. create the .aidl file, which defines the programming interface
2. implement the interface, which involves extending the inner abstract Stub class as well as implanting its methods.
3. expose the interface, which involves implementing the service to the clients.
What data types are supported by AIDL?
AIDL has support for the following data types:
all native Java data types like int, long, char and Boolean
What is a Fragment?
A fragment is a part or portion of an activity. It is modular in a sense that you can move around or combine with other fragments in a single activity. Fragments are also reusable.
Is it possible to use or add a fragment without using a user interface?
Yes, it is possible to do that, such as when you want to create a background behavior for a particular activity. You can do this by using add(Fragment, string) method to add a fragment from the activity.
How do you remove icons and widgets from the main screen of the Android device?
To remove an icon or shortcut, press and hold that icon. You then drag it downwards to the lower part of the screen where a remove button appears.
Do all mobile phones support the latest Android operating system?
Some Android-powered phone allows you to upgrade to the higher Android operating system version. However, not all upgrades would allow you to get the latest version. It depends largely on the capability and specs of the phone, whether it can support the newer features available under the latest Android version.
What is portable Wi-Fi hotspot?
Portable Wi-Fi Hotspot allows you to share your mobile internet connection to other wireless device. For example, using your Android-powered phone as a Wi-Fi Hotspot, you can use your laptop to connect to the Internet using that access point.
What is the difference between a regular bitmap and a nine-patch image?
In general, a Nine-patch image allows resizing that can be used as background or other image size requirements 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.
By Jilani Shaikh
Android Interview Questions And Answers For 2 Years Experience