Android Interview question

 In the year 2008, Android came as a popular computing platform, which is based on the Linux operating system. In the smartphone market, it became one of the most leading names that managed to change the whole. In the last ten years time, it grabs the majority of market share sharing with iOS and has effectively become the world's most popular operating system. With the maturity of Android, it is finding its new way into a variety of devices, not just on smartphones but also includes televisions, projectors, automobiles, and even now the vehicles.

Today with the advent of the Android platform, Android developers are huge in demand and every sector and industry is looking to recruit them in-house. If you aspire to be an Android developer, then this is just the place for you. Given below is the list of questions, which answers both basic and advanced concepts of Android. These questions if well prepared before an interview shall give an extra edge to the candidate and give confidence of facing the panel:

Read the best of 90+ Android Interview Questions for Senior Developer

We have listed below the best Android Interview Questions for Senior Developers. These Android Interview Questions are really very popular and asked various times in Android Interviews. So, practice these questions for the best preparation of Android Interviews. apart from this, you can also, download below the Android Interview Questions for Senior Developer PDF completely free.

 DOWNLOAD ANDROID INTERVIEW QUESTIONS PDF

Below are the list of Best Android Interview Questions and Answers

The major components of the Android App are listed below:

  • Activities
  • Services
  • Content Providers
  • Intents
  • Broadcast Receivers
  • Widgets
  • Notifications
  • Views
  • Fragments
  • Resources
  • App APK files
  • Layout XML Files
Loaded1.16%

The fragment in Android is as follows.

  • A fragment has its own layout and behavior with its own life cycle callbacks.
  • Fragments can be added or removed in an activity while the activity is running and used in multiple activities.
  • Multiple fragments can be combined in a single activity to build a multi-pane UI.
  • The fragment life cycle is closely related to the life cycle of its host activity which means when the activity is paused, all the fragments available in the activity will also be stopped
  • Fragments were added to the Android API in the Honeycomb version of Android API version 11.

Some storage options available in Android are listed below:

  • Shared Preferences
  • Internal Storage
  • External Storage
  • SQLite database

The full form of the APK is Android Package Kit which is the file format for applications used on the Android operating system;

 APK files are compiled with Android Studio, which is the official integrated development environment (IDE) for building Android software. An APK file includes all of the software program’s code and assets.

ANR is an abbreviation for Application not responding that describes an unresponsive Android app. an "ANR" event is triggered, When an app is running on an Android device and stops responding.

The DVM is an abbreviation for Dalvik Virtual Machine which is used to run Android applications. The DVM executes Dalvik bytecode.

Build Type is a build and packaging settings like signing configuration for a project. For instance, debug and release build types. The debug build type will use an android debug certificate for packaging the APK file. While the release build type will use a user-defined release certificate for signing and packaging the APK.

ARMv7 is a RISC(reduced instruction set computer) processor, with a Load/Store memory model. A Load/Store memory mode means memory access is restricted to specific instructions. An ARMV7 processor is a family of CPUs based on the RISC architecture developed by Advanced RISC Machines (ARM).

An Android activity is a screen of the Android app's user interface. It is similar to windows in a desktop application. An Android app may contain one or more activities that mean one or more screens

Android uses Intent for the communication between the components of an Application. The intent is the object which is used in android for passing the information among Activities in an Application. It also provides connectivity between two apps.

Take Free: Android MCQ & Quiz

NDK stands for The Native Development Kit which is a set of tools. It allows you to use C and C++ code with Android. It also provides platform libraries that you can use to manage native activities and access physical device components, such as sensors and touch input.

The Android Emulator imitates Android devices on your system. Therefore, users will be able to check your application on a spread of devices and Android API levels without having to possess every physical device. The emulator provides the majority of the capabilities of a real Android device

Android is an open-source operating system that can be useful for many tasks. An android application will undergo various states that are associatively called as Android Activity Life Cycle.

The lifecycle of activity consists of 7 methods:-

  1. onCreate() - The function onCreate() is called When a user first opens an activity that acts the same as a constructor of a class. 
  2. onStart() - The function onStart() is called when an activity becomes visible to the user and is called after onCreate.
  3. onResume() - The function onResume() is called just before the user starts interacting with the application.
  4. onPause() - The function onPause() is called when the app is partially visible to the user on the mobile screen.
  5. onStop() - The function onStop() is called when the activity is no longer on the activity stack and not visible to the user.
  6. onRestart() - The function onRestart() is called when the activity in the stopped state is about to start again.
  7. onDestroy() - The function onDestroy() is  called when the activity is cleared from the application stack.

The major difference between onCreate() and onStart() is as follows.

onCreate() is called when the Activity is created; that is, it is launched or started. (Additionally, this triggers when the orientation is changed.) It is called again when the process is killed, then returned to.

while onStart() called following onCreate() at startup. Additionally, it is also called when the app is navigated back to after onStop() (and following onRestart()), which occurs after the Activity is no longer visible (which is during the time that "the user can see the activity on-screen, though it may not be in the foreground and interacting with the user").

In Android, FLAG_ACTIVITY_CLEAR_TASK is used to end any previously existing task that helps to start new Activity in conjunction with FLAG_ACTIVITY_NEW_TASK.

Services in Android are a component that acts as an application to run in the background in order to perform long-running operation tasks.

The types of Services are listed below:

  • Background Services
  • Foreground Services
  • Bound Services

Android AsyncTask going to do background operation on the background thread and update on the main thread. In android, We can't directly touch the background thread to the main thread in android development. asyncTask helps us to make communication between the background thread to the main thread.

IntentService is a direct subclass for Services that handle asynchronous requests on demand. Clients send requests through Context. It is born to make things easier. It is also used to perform a certain task in the background. The instance of IntentService terminates itself automatically when needed.

A Handler is used to send and process Message and Runnable objects associated with a thread's MessageQueue. When a Handler created default bound with a Looper class. It will deliver messages and runnable to that Looper's message queue and execute them on Looper's thread.

Handlers are mainly used to Update the User Interface from a background thread, Enqueue a task for a different thread and Schedule a task for a specified time.

The onTrimMemory(int level) is used when the operating system has determined that a process to trim unneeded memory from its subprocess.

You can disable onBackPressed() by overriding it.

Some layouts available in Android are as follows:

  • Linear Layout
  • Relative Layout
  • Constraint Layout
  • Table Layout
  • Frame Layout
  • List View
  • Grid View
  • Absolute Layout
  • WebView
  • ScrollView

You can avoid ANR to perform long-running operations on the worker thread, not on the main thread. To create a worker thread, we can use AsyncTask class for long-running operations like File uploading, File downloading, etc

The Android software development kit (SDK) consists of a comprehensive set of development tools that includes a debugger, libraries, a handset emulator based on QEMU, documentation, sample code, and tutorials.

A Pending Intent is an action to require in the future. It allows you to pass a future Intent to a different application and permit that application to execute the Intent.

AndroidManifest.xml file is responsible to protect the application from accessing any protected parts by providing the permissions. Every app project has an AndroidManifest.xml file which is also the root of the project source set. This file contains information about your package, Android operating system, the Android build tools, Google Play, and other including components of the application such as activities, content providers, services, broadcast receivers, etc.

The Intent is used with sticky broadcast, which is called sticky intent. This intent will stick with the android system for future broadcast receiver requests.

A Fragment represents a reusable portion of your app's User Interface. Retained Fragment consists of the configuration change that causes the underlying Activity to be destroyed. The term "retained" refers to the fragment that will not be destroyed on configuration changes.

The Android platform provides several sensors that are used to monitor the motion of a device. The sensors' possible architectures vary with sensor types such as the gravity, linear acceleration, rotation vector, significant motion, step counter, and step detector sensors that are either hardware-based or software-based.

Different launch modes are explained below:

  • Android Launch mode 'Standard' — Multiple instances every time, A very default launch mode!
  • Launch mode 'SingleTop' — Multiple instances Conditionally
  • Specialized Launch mode 'SingleTask' — Single instance throughout System.
  • Specialized Launch mode 'SingleInstance' — Single instance throughout System.

In an application, An Intent is a messaging object that can be used to request an action from another app component. It specifies the type of intents that the component would like to receive. For instance, you make it possible for other apps to directly start your activity with a certain kind of intent by declaring an intent filter for an activity.

SQLite is an embedded SQL database engine with multiple tables, indices, triggers, and views, contained in a single disk file. SQLite modifies data directly to ordinary disk files.

AppCompatActivity is the base class for activities with the support library action bar features. ActionBar can be added to your activity by extending this class for your activity and setting the activity theme to Theme when running on API level 7 or higher.

Proguard detects and removes unused classes, fields, methods, and attributes. Mobile app development companies use the Proguard in android, it optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods by using short meaningless names.

An android application includes Activities that form a stack like a deck of cards. When you start an android application and start five activities A, B, C, D, E. Then they will form a stack such as:

E for chat view

D for weather screen

C for map view

B for weather screen

A for the login screen

Android Toast displays information for a short period of time that contains a message to be displayed quickly and disappears after some time. It also used to show notifications for a particular interval of time at the bottom of the screen by default.

Shared Preferences persist data across user sessions that should be remembered across sessions, such as user’s preferred settings or their game score, even if the app is killed and restarted, or the device is rebooted.

StateListDrawable is a java class of Android, that is used for drawable contents in an application.

The drawer Layout is the root layout. It defines a FrameLayout and a Navigation View. In Navigation View we set the items from the menu file and FrameLayout is used to replace the Fragments on the click of menu items.

Android Jetpack is a set of Android components, tools, and guidance inspired by the backward compatibility of the Support Library and Android Architecture Components that are platform-independent, allowing your app to run on multiple Android platforms.

You can Start android background service as follows:

Intent intent = new Intent(Activity.this, MyBackgroundService.class);
startService(intent);
You can Stop android background service as follows:
Intent intent = new Intent(Activity.this, MyBackgroundService.class);
stopService(intent);


The bound service is a server in a client-server interface that allows components such as activities to bind to the service, send requests, receive responses, and perform interprocess communication (IPC).

A DialogFragment is a fragment that floats on top of the current activity window and displays a modal window. An instance of DialogFragment can be used to display an existing Dialog implementation dialog or a custom view hierarchy by using the Dialog class that is the base class for implementing a dialog.

The Presenter acts as a mediator between model and view. All your presentation logic belongs to the presenter which is responsible for querying the model and updating the view, reacting to user interactions, and updating the model.

You can avoid continuous allocation and deallocation of memory in your application by using the Bitmap pool, you can reduce GC overhead, which results in a smooth-running application.

Android Recycler View is a version of ListView. It has improved performance and other benefits. You can use RecyclerView and CardView together, which creates both lists and grids very easily.

A view holder design pattern is used to speed up the rendering of your ListView to make it work smoothly, findViewById is quite expensive when used each time a list item is rendered, it must traverse your layout hierarchy.

Rooting is the process of attaining users privileged control known as root access over various Android subsystems to allowing Android mobile operating systems to run on smartphones, tablets, and other devices.

Android WebView is a system component that allows Android apps to display web content. It is pre-installed on your device and should be kept up to date to ensure you have the latest security updates and other bug fixes.

A SurfaceView is a view in a view hierarchy that has its own separate Surface. It also provides a dedicated drawing surface embedded inside of a view hierarchy.

Scannable is a Spanned, adding in the ability to modify the spans to add or remove formatting, but not to modify the text itself.

Samsung DeX is a feature that is included on some high-end Samsung handheld devices. It enables users to extend their device into a desktop-like experience by connecting a keyboard, mouse, and monitor. Samsung DeX is also a platform that turns your smartphone into a desktop computing experience.

The Espresso is a testing framework for Android. It is an easier way to write reliable user interface tests. It automatically synchronizes your test actions with the UI of your application. It also ensures that your activity is started before the tests run.

Android is an open-sourced operating system by Linux that is primarily used in mobile devices like cell phones and tablets. This Linux kernel based system is equipped with high and advanced components that allow developers to create and run apps. Therefore performs the basic as well as the advanced functions.

Android application components are the building block essentially used in the Android application. The application manifest file named Android manifest.xml couples the components. This describes each component of the application and describes how they interact, and then the processing activity takes place.

There are four main components, which are:

  • Activities: They show the UI and handle the interaction of the users in smartphone screen.
  • Services: They take care of the processing associated with the application.
  • Broadcast Receivers: They handle the communication process between Android OS and application.
  • Content Providers: They handle issues with data and database management.

A fragment means behavior or the portion of user interface in a Fragment Activity. One can combine multiple fragments in a single activity to build a UI and can reuse the fragment in multiple activities. The fragment can be considered as a modular section of an activity. This has its life cycle, gets its input events, which can be added or removed accordingly. It is must host a fragment in an activity and fragments lifecycle is directly related by the host activity’s lifecycle.

Android provides some options to save or store the app data. Here the choice depends on the specific needs and requirement of space by the users.

Few of the data storage options available on Android are as follows:

  • Internal file storage: stores the private file on the device file system.
  • External file storage: stores the file on the shared external file system.
  • Shared preferences: stores the private primitive data in key-value pairs.
  • Databases: stores the structured data in a private database.

To expose one app’s data to other apps, the content provider can be used.

AIDL is Android Interface Definition Language. This IDL allows the user to define the programming interface; both the clients and service agree upon to communicate with each other using inter-process communication (IPC). On Android platform, it becomes difficult for one processor to access the memory of another process. They need to decompose their objects into primitive that the operating system can manage, and marshal the objects across. The code to perform that marshaling is tedious to write therefore Android handles this for the users with the help of AIDL

Services here is an application component that can perform long-duration operations in the background. It doesn’t provide a user interface. Other application components can start a service and can continue to perform/ run in the background when the users switch to some other application. There are three different types of services:

  • Foreground: The activity of performing the operation in foreground service is noticeable to the users. A notification is displayed for the same.
  • Background: Generally, a background service performs its operations, which is directed not noticed by the users on their screen. Example if an app uses service to compact its storage this will be considered as background service.
  • Bound: A service is bound when an application component binds to it by calling it as bind service. A bound service runs only as long as another application component is bound to it.

Every application should have an Androidmanifest.xml file at the root of the project source set. This file describes the essential information required by the user for the app to the Android build tools. Apart from this, it is required for the following reasons:

  • To give permission that the application requires to ensure the access is protected.
  • To provide with the hardware and software features, which the app requires when installing from Google play etc.

It is an instruction for Android OS that specifies how the activity should be launched or performed. The activities are performed into two areas, which are:

  • Tasks: It’s a collection of activities, with which the users interact when they perform certain jobs. An application contains a number of activities.
  • Back Stack: Back stack in a back stack the activities are arranged with the order in which each is opened. This maintained stack called back stack.

Sticky intent sticks with the Android for future broadcast listeners. For instance, if Battery low event occurs then that intent will be stick with Android, so that if any future user requested for Battery – Low, it will be fired.

Serializable is a standard Java interface. It is not a part of the Android SDK. Its simplicity is its biggest beauty. Just by implementing this interface the POJO will be ready to jump from one particular activity to another. There is another interface known as parseable. It is a part of the Android SDK. Paracelable was specifically designed in a way that there is no reflection left while using.

The architecture of Android application has few components, which have their functions to perform:

  • Service: It performs the background functions
  • Intent: Performs the interconnection function between activities and data passing mechanism
  • Resource: Externalization it is used to perform strings and graphics functions
  • Notification: This shows the lights, sound, icon, notification, incoming chats messages dialogue box, etc.
  • Content providers: It shares the data between applications.

Following are the code names with year:

  1. Astro
  2. Blender
  3. Cupcake (April 2009)
  4. Doughnut (September 2009)
  5. Eclair (October 2009)
  6. Froyo (may 2010)
  7. Gingerbread (December 2010)
  8. Honeycomb (February 2011)
  9. Ice Cream Sandwich (October 2011)
  10. Jellybean (July 2012)
  11. Kitkat (October 2013)
  12. Lollipop (November 2014)
  13. Marshmallow (since October 2015)

Advantages of Android are as follows:

  • It is an Open source that requires no licensing
  • It is Platform independent that supports Windows, Mac, and Linux platforms.
  • Supports different technologies like camera, Bluetooth, wifi, speech, EDGE, etc.
  • It is a highly optimized virtual machine.

Android supports C++, C. The app can be developed in C or C++ using Android NDK (Native development kit). This makes system works faster.

There are seven lifecycle methods of Android activities. They are:

  • On create()
  • On start()
  • On resume()
  • On pause()
  • On stop()
  • On restart()
  • On destroy()

DDMS is Dalvik Debug Monitor Server.This gives a wide array of debugging features of which are

  • Port forwarding services
  • Screen capture
  • Thread and heap information
  • Network traffic tracking
  • Location data
  • spoofing

Dialogue box supported by Android are:

  • Alert dialogue
  • Process dialogue
  • Data picker dialogue
  • Time picker dialogue

These are the following exceptions in Android:

  • Inflate exception
  • Surface.out of resource exception
  • Surface holder bad surface type exception
  • Window manager took exception.

Tools used to develop an Android app are as follows:

  • JDK
  • Eclipse +ADT Plugin
  • SDK Tools

The Google Android SDK is a set of tools that are used by the developers to write the app on Android-enabled devices. It contains a graphical interface that emulates an Android-driven handheld environment and allows the developers to debug their codes as per the requirements.

A nine- patch image allows the resizing of the image that can be used as background or other image size requirements for the target device. The nine- patch refers to the way one can resize the image. It can be done in the in the following manners

  • 4-image corner unscaled one.
  • Four edges, scaled in 1 axis
  • The last middle one that can be scaled into both the axes.

Portable Wi-Fi hotspot allows the users to share a mobile Internet connection with another device. Using an Android powered phone as a Wi-Fi hotspot user can use their laptop to connect to the Internet using the same access point.

XML based layouts provide a consistent and standard means of setting GUI format. In general use, layout details are placed in XML files, and all other items are generally placed in a source files.

Orientation is set using set orientation (), dictates whether the linear layout is represented as a row or else as a column. There the values are set as HORIZONTAL or VERTICAL.

Activities can be closed or can be terminated easily as and when the user wants to. Services are designed to run on the background or behind the scenes and can act independently. Most of the services run on a continuous basis regardless of their certain or no certain activities been executed.

The emulator lets the developers “play” all around the interface that gives the experience of an actual mobile device. It is for writing and testing codes, and debug too. Emulators are safe for testing codes especially if the user is in the early stage of design.

Permission allows certain restrictions to be imposed primarily to protect data and code. Without this, codes could be compromised, resulting in defects in the actual function.

AAPT is Android Asset packing tool. This provides developers with the ability to deal with zip-compatible archives, and it includes creating, extracting as well as viewing its content.

Few of the disadvantages of Android in the mobile market are as follows:

  • Developers can write and register apps that will only run under the Android environment.
  • With the growing popularity and demand for the Android mobile devices, developers can easily take advantage of this trend by uploading the app on the market for the distribution purpose, and people can download it.

The four initial stages of the activity are as followed:

  • Active: If the activity is in the foreground that means it is running on the device.
  • Paused: When the activity is at the background and is still visible on the screen.
  • Stopped: when the activity is not visible and is actually hidden by another activity that is running on the device.
  • Destroyed: when the activation process is killed or is terminated, it’s considered to be completely destroyed.

Activities are windows to an interface. Like a window is created with the aim to display the output and to know about input in the form of a dialogue box. In the same manner, activities play its role, may not always in the form of a user interface.

Intents help to display the notification message to the user from within the Android device. Users are made to response this alert.

The important items for Android projects are:

  • AndroidManifest.xml
  • Build.xml
  • Bin/
  • Src/
  • Res/assets/

In a general term, the container means some object that can be used to hold or to procure. In a similar manner here, containers are used to hold objects and the widgets altogether.It depends on which specific item is it required and what kind of arrangement is needed. It can be used to hold labels, fields or buttons.

Dalvik plays an important role in the development of Android. It acts as a virtual machine where the Android application runs. It is with the help of Dalvik only that devices can execute multiple virtual machines effectively along with better memory management.

Follow the below steps to create a bounded service through AIDL

  • Step 1. Create the .aidl file that defines the programming interface.
  • Step 2. Implement the interface, by extending the inner abstract stub class and imparting its methods.
  • Step 3. Expose the interface by implementing the service to the users.

Default resources contain the default string and files. If this resource is not present the error will keep occurring, and the app will not be able to run. Resources are placed in subdirectories under the project res/ directory. Moreover, therefore helps the app to function in the desired conditions.

Fragments are reusable in nature and is a portion of an activity. In other words, it is modular that can be combined or is movable in an activity.

Terminating or killing the foreground activity is the last and final savior. It is generally desirable or is the best time to kill this activity when it is consuming too much of memory. When the memory paging state is reached by the activity, it is killed so that the interface can sustain the responsiveness of the user of the application.

There are basically three kinds of intent in Android which are intent, sticky intent and pending intent. Sticky intent is the one that sticks with Android and helps in the future broadcast of listeners. Like in the case of BATTERY_LOW, the sticky intent will stick to the Android so that in future if the request appears again then it will return the BATTERY_LOW intent. In short words, sticky intent is the one that helps in the easy communication between service and function. This intent allows broadcasting and performing operations even after the completion of the intent. For example, ACTION_BATTERY_CHANGED will be operated after the call of registerReceiver() for performing the action.

The supporting facility of Android new version depends on the capabilities and specs of the phone. There are few Android power phones that allow the user to update their version to the higher operating version. Few don’t allow getting the updated version work. Either the new feature will not be supported, or the performance of the operating device will slow down.

In the latest update of Android version 6.0, the official Android code name is known as a marshmallow. It was launched in May 2015. This was the successor of the Android version 5.0 named as Lollipop. Google named this version as a marshmallow on 17th August 2015 for Nexus devices.

Runnable is a concurrent unit of execution in Android. It is also a class that implements a Runnable interface. The Runnable interface is used extensively to execute code in Threads.

Also Read Related Android Interview Questions

Kotlin Interview QuestionsAndroid MCQ

Comments

Popular posts from this blog

Difference between Imperative Approach and Reactive Approach

The 10 Most Popular Coding Challenge Websites 2021

Java - Recursion