Android Interview Questions and Answers

1) What is Android?

Android is a mobile operating system developed by Google, based on the Linux kernel and designed primarily for touchscreen mobile devices. It has been equipped with rich components that allows developers to create and run apps that can perform both basic and advanced functions.

2) What is the google Android SDK?

The Android <strong>software development kit</strong> (SDK) includes a comprehensive set of development tools which is a toolset that developers need in order to write apps on Android enabled devices. It contains a graphical interface that emulates an Android driven handheld environment, allowing them to test and debug their codes.

3) What is the Android architecture?

Android architectue is divided into following five parts.<br/> <strong>linux kernel<br/> native libraries (middleware),<br/> Android Runtime<br/> Application Framework<br/> Applications</strong>

4) Explain .apk extension.

<strong>Android application package (APK)</strong> is the package file format used by the Android operating system for distribution and installation of mobile apps and middleware. APK files are a type of archive file, specifically in zip format packages based on the JAR file format, with .apk as the filename extension. The MIME type associated with APK files is application/

5) What is AAPT?

<strong>AAPT (Android Asset Packaging Tool)</strong> allows you to view, create, and update Zip-compatible archives (zip, jar, apk). It can also compile resources into binary assets. It is the base builder for Android aplications.

6) What is the importance of having an emulator within the Android environment?

Basically emulator helps you to run your application there itself in the PC, you needn't require any android phone to test your application.<br/> Developers use emulator for quick testing of the apk at the machine itself.

7) What method does Android follow to track applications?

It is done by assigning each application with a unique ID (referred as Linux User ID).

8) What is the use of an activityCreator?

An ActivityCreator is the first step towards the creation of a new Android project. It is made up of a shell script that will be used to create new file system structure necessary for writing codes within the Android IDE

9) Describe activities?

<strong>Activity</strong> - represents the presentation layer of an Android application, e.g. a screen which the user sees. An Android application can have several activities and it can be switched between them during runtime of the application.

10) What are intents?

An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a Background Service.

11) What is referred to Explicit and Implicit Intent?

<strong>Explicit Intent:</strong> Explicit intent names the component.<br/><strong>Implicit Intent:</strong> Implicit Intents have not specified a component.<br/> eg: The java class which should be called Implict intent asked the system to perform a service without telling the system which java class should do this service.

12) Differentiate Activities from Services?

<strong>Activity </strong>: 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. Although the activities work together to form a cohesive user experience in the email application, each one is independent of the others. An activity is implemented as a subclass of Activity.<br/> <strong>Service:</strong> A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity.A service is implemented as a subclass of Service

13) What items are important in every Android project?

The android project structure definitely stands on the following items if one is left off the ; the android application would not work properly.The items involve in adroid project are described below: <strong>AndroidManifest.xml<br/>build.xml<br/>bin/<br/>src/<br/>res/<br/>assets/</strong>

14) 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.<br/> In common practice, layout details are placed in XML files while other items are placed in source files.

15) What are containers?

Containers is a bucket description for Views that wrap dynamic content. They are more specialized than Layouts and can but doesn't have to extend a Layout. Some extend ViewGroup indirectly e.g ListView, some don't e.g. VideoView. The Container label is used in Android Studio but is not part of the class name.

16) 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.

17) what is the importance of Android in mobile market?

Developers can write and register apps that will specifically run under the Android environment. This means that every mobile device that is Android enabled will be able to support and run these apps. With the growing popularity of Android mobile devices, developers can take advantage of this trend by creating and uploading their apps on the Android Market for distribution to anyone who wants to download it.

18) What do you think are some disadvantages of Android?

Little Memory for Storage<br/>Force Close on Large App/Games<br/>Data Connection<br/>Battery Problem<br/>Box of Malware Google play store<br/>

19) what is adb?

Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components:<br/> A client, which sends commands. The client runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as DDMS also create adb clients.<br/> A daemon, which runs commands on a device. The daemon runs as a background process on each emulator or device instance.</br> A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.<br/>

20) What are 4 essential states of an activity?

<strong>Active</strong> – if the activity is at the foreground<br/> <strong>Paused</strong> – if the activity is at the background and still visible<br/> <strong>Stopped</strong> – if the activity is not visible and therefore is hidden or obscured by another activity<br/> <strong>Destroyed</strong> – when the activity process is killed or completed terminated

21) What is ANR?

<strong>ANR</strong> stands for A pplication N ot R esponding.<br/>An ANR will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned. After the 5 seconds approx has occurred, if the thread still hasn't recovered then an ANR dialogue box is shown informing the user that the application is not responding and will give the user the choice to either wait, in the hope that the app will eventually recover, or to force close the app.

22) What is the difference between ANR and crash in Android?

An <strong>ANR</strong> will occur if you are running a process on the UI thread which takes a long time, usually around 5 seconds. During this time the GUI (Graphical User Interface) will lock up which will result in anything the user presses will not be actioned. After the 5 seconds approx has occurred, if the thread still hasn't recovered then an ANR dialogue box is shown informing the user that the application is not responding and will give the user the choice to either wait, in the hope that the app will eventually recover, or to force close the app.<br/> A <strong>crash</strong> is when an exception within the app has been thrown which has not been handled. For example, if you try to set the text of an EditText component, but the EditText is null and there is no try catch statement to catch the exception that your app will crash and will be force closed. The user will not see what caused the crash, they will be shown a dialogue telling that the app has force closed unexpectedly and will give them the option to send a bug report. In this example if you were to look in the bug report you would see the error caused by java.lang.NullPointerException.

23) Which elements 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.

24) How are escape characters used as attribute?

Escape characters are preceded by double backslashes. For example, a newline character is created using ‘\\n’

25) What is the importance of setting permissions in app development?

Set permission helps in setting restriction for data protection and code can be set up using permission. In the absence of permission, codes could get compromised which can lead to defects in functionality.

26) What is the function of an intent filter?

An intent filter is an expression in an app's manifest file that specifies the type of intents that the component would like to receive.<br/>When you create an implicit intent, the Android system finds the appropriate component to start by comparing the contents of the intent to the intent filters declared in the manifest file of other apps on the device. If the intent matches an intent filter, the system starts that component and delivers it the Intent object.

27) Enumerate the three key loops when monitoring an activity?

<Strong>Entire lifetime</strong> – activity happens between onCreate and onDestroy<br/> <Strong>Visible lifetime</Strong> – activity happens between onStart and onStop<br/> <Strong>Foreground lifetime</Strong> – activity happens between onResume and onPause

28) When is the onStop() method invoked?

A call to onStop method happens when an activity is no longer visible to the user, either because another activity has taken over or if in front of that activity.

29) Is there a case wherein other qualifiers in multiple resources take prededence 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.

30) What are the different states wherein a process is based?

There are 4 possible states:<br/> <strong>foreground activity<br/> visible activity<br/> background activity<br/> empty process</strong>

31) How can the ANR be prevented?

One technique that prevents the Android system from concluding a code that has been responsive for a long period of time is to create a child thread. Within the child thread, most of the actual workings of the codes can be placed, so that the main thread runs with minimal periods of unresponsive times.

32) What roles does Dalvik play in Android development?

Dalvik i.e Dalvik Virtual machine is used to run your android projects. Usually, android apps are written in java and compiled to bytecode version using java virtual machine (JVM) which is then translated to Dalvik bytecode or .dex file.

33) What is AndroidManifest.xml?

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest file provides essential information about your app to the Android system, which the system must have before it can run any of the app's code.

34) What is the proper way of setting up an Android-powered device for app developemnt?

The following are steps to be followed prior to actual application development in an Android-powered device:<br/> -Declare your application as “debuggable” in your Android Manifest.<br/> -Turn on “USB Debugging” on your device.<br/> -Set up your system to detect your device.

35) Enumerate the steps in creating a bounded service through AIDL?

<strong>1.</strong>create the .aidl file, which defines the programming interface.<br/> <strong>2.</strong> implement the interface, which involves extending the inner abstract Stub class as well as implanting its methods.<br/> <strong>3. </strong>expose the interface, which involves implementing the service to the clients.

36) What is the importance of Default Resources?

When default resources, which contain default strings and files, are not present, an error will occur and the app will not run.<br>Resources are placed in specially named subdirectories under the project res/ directory.

37) When dealing with multiple resources , which one takes precedence?

Assuming that all of these multiple resources are able to match the configuration of a device, the ‘locale’ qualifier almost always takes the highest precedence over the others.

38) When does ANR occur?

The ANR wil occur when long running operations performed on the Main Thread. When a long running operations will perform Main thread is not responsive at some time in these scenariosAccess Network State,Getting dataServer. The responseServer will take some time, in this time the Main thread is ideal. So The ANR will occur at these situations. To avoid those use Threads, Handlers,AsyncTask and Cursor Loaders based on your requirement.

39) What is AIDL?

AIDL (Android Interface Definition Language) is similar to other IDLs you might have worked with. It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

40) What data types are supported by AIDL?

By default, AIDL supports the following data types:<br/> All primitive types in the Java programming language (such as int , long , char , boolean , and so on)<br/> String.<br/> CharSequence.<br/> List. ...<br/> Map.<br/>

41) What is a Fragment?

A fragment is usually used as part of an activity's user interface and contributes its own layout to the activity. To provide a layout for a fragment, you must implement the onCreateView() callback method, which the Android system calls when it's time for the fragment to draw its layout.

42) What is a visible activity?

A visible activity is one that sits behind a foreground dialog. It is actually visible to the user, but not necessarily being in the foreground itself.

43) When is the best time to kill a foreground activity?

If system is low on memory it kills some processes to make some space that operating system can run. So that it starts killing starting from low priority to high (5 to 1). If your foreground activity is destroyed, system has very very low memory to run and even operating system may crash soon.

44) Is it possible to use or add a fragment without using a user intrface?

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.

45) 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.

46) What are the core components under the android application architecture?

There are 5 key components under the Android application architecture:<br/> <strong>services<br/> intent<br/> content providers<br/> resource externalization<br/> notifications</strong>

47) What composes a typical Android application project?

A project under Android development, upon compilation, becomes an .apk file. This apk file format is actually made up of the AndroidManifest.xml file, application code, resource files, and other related files.

48) What is sticky intent?

A Sticky Intent is a broadcast from sendStickyBroadcast() method such that the intent floats around even after the broadcast, allowing others to collect data from it.

49) 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.

50) 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.

51) What is an action?

In Android development, an action is what the intent sender wants to do or expected to get as a response. Most application functionality is based on the intended action.

52) 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.

53) What language is supported by Android for application development?

The main language supported 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.

Is this page helpful to you? Please give us your feedback below. We would love to hear your thoughts on these articles, it will help us improve further our learning process.