android Interview Questions and Answers

android interview questions and answers.Contains frequently asked interview questions on android for freshers and experienced.

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 software development kit (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.
linux kernel
native libraries (middleware),
Android Runtime
Application Framework
Applications

4)   Explain .apk extension.

Android application package (APK) 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/vnd.android.package-archive.

5)   What is AAPT?

AAPT (Android Asset Packaging Tool) 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.
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?

Activity - 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.

Other Interview Questions

11)   What is referred to Explicit and Implicit Intent?

Explicit Intent: Explicit intent names the component.
Implicit Intent: Implicit Intents have not specified a component.
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?

Activity : 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.
Service: 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: AndroidManifest.xml
build.xml
bin/
src/
res/
assets/

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.
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
Force Close on Large App/Games
Data Connection
Battery Problem
Box of Malware Google play store

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:
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.
A daemon, which runs commands on a device. The daemon runs as a background process on each emulator or device instance.
A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.

20)   What are 4 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

21)   What is ANR?

ANR stands for A pplication N ot R esponding.
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 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.
A crash 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.
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?

Entire lifetime – activity happens between onCreate and onDestroy
Visible lifetime – activity happens between onStart and onStop
Foreground lifetime – 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:
foreground activity
visible activity
background activity
empty process

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:
-Declare your application as “debuggable” in your Android Manifest.
-Turn on “USB Debugging” on your device.
-Set up your system to detect your device.

35)   Enumerate 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.

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.
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:
All primitive types in the Java programming language (such as int , long , char , boolean , and so on)
String.
CharSequence.
List. ...
Map.

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:
services
intent
content providers
resource externalization
notifications

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.