Android Interview Question Answers

Q1: What is Android?

Android is a mobile operating system initially developed by Android Inc. Android was bought by Google in the year 2005. The Android software is based upon a modified version of the Linux kernel. 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.

Q2: Features supported by Android?

Features Supported by Android:
Handset layouts:The platform is adaptable to larger, VGA, 2D graphics library, 3D graphics library based on OpenGL ES 2.0 specifications, and traditional smartphone layouts.
Storage: SQLite, a lightweight relational database, is used for data storage purposes
Connectivity: Android supports connectivity technologies including GSM/EDGE, IDEN, CDMA, EVDO,UMTS, Bluetooth, Wi-Fi, LTE, and WiMAX.
Messaging: SMS and MMS are available forms of messaging, including threaded text messaging and now Android Cloud to Device Messaging Framework (C2DM) is also a part of Android Push Messaging service.
Web browser: The web browser available in Android is based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript engine.
Media support: Android supports the following audio/video/still media formats: WebM, H.263,H.264 (in 3GP or MP4 container), MPEG-4 SP, AMR, AMR-WB (in 3GP container),AAC, HE-AAC (in MP4 or 3GP container), MP3, MIDI, Ogg Vorbis, WAV, JPEG,PNG, GIF, BMP.
Multitasking: Multitasking of applications is available.

Q3: What are the key components of Android Architecture?

Android Architecture consists of 4 key components:
- Linux Kernel:Linux Kernel Core services (including hardware drivers, process and memory management, security, network, and power management) are handled by a Linux 2.6 kernel. The kernel also provides an abstraction layer between the hardware and the remainder of the stack.
- Libraries:Libraries Running on top of the kernel, Android includes various C/C++ core libraries such as libc and SSL, as well as:media library,Graphics libraries,SQLite etc
- Android Framework:Framework provides the classes used to create Android applications. It also provides a generic abstraction for hardware access and manages the user interface and application resources.
- Android Applications:All applications, both native and third party, are built on the application layer using the same API libraries. The application layer runs within the Android run time using the classes and services made available from the application framework.

Q4: Explain Android Project Structure? - Activity java files having java code for activity logic. - File containing an ID for all asset constants.
Android Library/ Folder - containing all Android’s SDK files.
assets/ - Multimedia and other miscellaneous required files.
res/ - Base directory for resources used by the UI.
res/drawable - Directory for image files.
res/layout - All XML-style view layout files.
res/values - Location for string’s and configuration files.
AndroidManifest.xml - File that describes your application.

Q5: What is an Activity?

A single screen in an application, with supporting Java code.Activities use Views to form graphical user interfaces that display information and respond to user actions. In terms of desktop development, an Activity is equivalent to a Form.

Q6: What is Service?

Services doesn't have visual interface and runs in background. Service components run invisibly, updating your data sources and visible Activities and triggering Notifications. They’re used to perform regular processing that needs to continue even when your application’s Activities aren't active or visible.

Q7: 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).
Implicit Intent: In case of Implicit Intent, an intent is just declared.
- It is for the platform to find an activity that can respond to it.
- Since the target component is not declared, it is used for activating components of other applications.
Explicit Intent: Explicit intent specifies the particular activity that should respond to the intent.
- They are used for application internal messages.

Q8: What is a Sticky Intent?

sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. 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.

Q9: What are Broadcast Receivers?

BroadcastReceiver is a component that does nothing but receive and react to broadcast announcements.
For example, the battery is low or that the user changed a language preference.

Q10: What are content provider?

Provides content to applications.The data can be stored in the file system, in an SQLite database, or in any other manner that makes sense. Android devices include several native Content Providers that expose useful databases like contact information.

Q11: Explain Android Manifest file?

Manifest file for an android application is a resource file which contains all the details needed by the android system about the application.

AndroidManifest.xml allows us to define:
- The packages, API, libraries needed for the application.
- Basic building blocks of application like activities, services and etc.
- Details about permissions.
- Set of classes needed before launch.

Q12: How is nine-patch image different from a regular bitmap?

It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.

Q13: What is a resource?

A user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.

Q14: What is .dex extension?

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.

Q15: What is .apk extension?

The extension for an Android package file, which typically contains all of the files related to a single Android application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.

Q16: What is Mono for Android?

Mono for Android is a software development kit that allows developers to use the C# language to create mobile applications for Android-based devices.

Q17: Can you deploy executable JARs on Android? Which packaging is supported by Android?

No. Android platform does not support JAR deployments.
Applications are packed into Android Package (.apk) using Android Asset Packaging Tool (aapt) and then deployed on to Android platform. Google provides Android Development Tools for Eclipse that can be used to generate Android Package.

Q18: How will you record a phone call in Android? or How to handle an Audio Stream for a call in Android?

Permission.PROCESS_OUTGOING_CALLS: Will Allow an application to monitor, modify, or abort outgoing calls. So using that permission we can monitor the Phone calls.

Q19: When does Android start and end an application process?

Android starts an application process when application's component needs to be executed. It then closes the process when it's no longer needed (garbage collection).

Q20: Does Android support the Bluetooth serial port profile?


Q21: Can an application be started on powerup?


Q22: 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.

Q23: What is an DDMS?

Dalvik Debug Monitor Service (ddms):
• Integrated with Dalvik – the Android platform's custom VM – this tool lets you manage processes on an emulator or device and assists in debugging. You can use it to kill processes, select a specific process to debug, generate trace data, view heap and thread information, take screenshots of the emulator or device, and more.

Q24: Explain Activity Life Cycle?

An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails.

Activity callback methods are as follows:
onCreate():This is the first callback and called when the activity is first created.
onStart():This callback is called when the activity becomes visible to the user.
onResume():This is called when the user starts interacting with the application.
onPause():The paused activity does not receive user input and cannot execute any code and called when the current activity is being paused and the previous activity is being resumed.
onStop():This callback is called when the activity is no longer visible.
onDestroy():This callback is called before the activity is destroyed by the system.
onRestart():This callback is called when the activity restarts after stopping it.

Q25: What is Drawable?

A compiled visual resource that can be used as a background, title, or other part of the screen. It is compiled into an subclass.

Q26: 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.

Q27: 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.

Q28: How many ways data stored in Android?

2.Internal Storage
3.External Storage
4.SQLite Database
5.Network connection

Q29: What is Orientation?

Orientation decides if the LinearLayout should be presented in row wise or column wise fashion.
- The values are set using setOrientation()

Q30: What is AIDL?

AIDL is the abbreviation for Android Interface Definition Language.
- It handles the interface requirements between a client and a service to communicate at the same level through interprocess communication.
- The process involves breaking down objects into primitives that are Android understandable.

AIDL supports following data types:
-charSequence and
-all native Java data types like int,long, char and Boolean

Q31: How to achieve localization in java?

Locale specific string data can be put to respective values folder under the res directory to achive localization
– values
– values-pt
– values-sp
– values-fr

Q32: What are Views?

Views are the basic User Interface class for visual interface elements (commonly known as controls or widgets). All User Interface controls, and the layout classes, are derived from Views.

Q33: What are ViewGroups?

ViewGroups are extensions of the View class that can contain multiple child Views. By extending the ViewGroup class, you can create compound controls that are made up of interconnected child Views. The ViewGroup class is extended to provide the layout managers, such as LinearLayout, that help you compose the User Interfaces.

Q34: What are Layouts?

Layout Managers (commonly known as “layouts”) are extensions of the ViewGroup class designed to control the position of child controls on a screen. Layouts can be nested, allowing you to create arbitrarily complex interfaces using a combination of Layout Managers.

Types of Layouts:
– LinearLayout
– RelativeLayout
– FrameLayout
– TableLayout
– AbsoluteLayout

Q35: What are adapters?

Adapters are bridging classes that bind data to user-interface. AdapterView is a ViewGroup subclass whose child Views are determined by an Adapter that binds to data of some type. AdapterView is useful whenever you need to display stored data (as opposed to resource strings or drawables) in your layout.

Gallery, ListView, and Spinner are examples of AdapterView.

AdapterView objects have two main responsibilities:
• Filling the layout with data
• Handling user selections

Android supplied adapters
– ArrayAdapter
– SimpleCursorAdapter

Q36: Explain Service Life Cycle?

A service is a component that runs in the background to perform long-running operations without needing to interact with the user. For example, a service might play music in the background while the user is in a different application.

Service Callback methods are as follows:
onStartCommand():The system calls this method when another component, such as an activity, requests that the service be started, by calling startService(). If you implement this method, it is your responsibility to stop the service when its work is done, by calling stopSelf() or stopService() methods.
onBind():The system calls this method when another component wants to bind with the service by calling bindService(). If you implement this method, you must provide an interface that clients use to communicate with the service, by returning an IBinder object. You must always implement this method, but if you don't want to allow binding, then you should return null.
onUnbind():The system calls this method when all clients have disconnected from a particular interface published by the service.
onRebind():The system calls this method when new clients have connected to the service, after it had previously been notified that all had disconnected in its onUnbind(Intent).
onCreate():The system calls this method when the service is first created using onStartCommand() or onBind(). This call is required to perform one-time setup.
onDestroy():The system calls this method when the service is no longer used and is being destroyed. Your service should implement this to clean up any resources such as threads, registered listeners, receivers, etc.

Q37: Networking support in Android?

Android contains the Apache HttpClient library and this library is the preferred way of performing network operations in Android. Android also allows access to the network via the standard Java Networking API ( package). Even if you use the package, Android will internally use the Apache library.
To access the internet your application requires the "android.permission.INTERNET" permission.

Q38: What is Pending Intent?

A.The PendingIntent class provides a mechanism for creating Intents that can be fired by another application at a later time. A pending Intent is commonly used to package an Intent will be fired in response to a future event,such as a widget View being clicked or a Notification being selected from the notification panel.