Top 25 Android Interview Questions and Answers

 

1.What is Android ?

Android is a 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.

2.What are the different data types used by Android?

The data can be passed between many services and activities using the following data types:

– Primitive Data Types: This is used to share the activities and services of an application by using the command as Intent.putExtras(). This primitive data passes the command to show the persistent data using the storage mechanism. These are inbuilt data types that are used with the program. They provide simple implementation of the type and easy to use commands.

– Non-Persistent Objects: It is used to share complex and non-persistent objects. These are user-defined data types that are used for short duration and are also recommended to be used. These types of objects allow the data to be unique but it creates a complex system and increase the delay.

3.What main components of Android application?

  1. Activities: They dictate the UI and handle the user interaction to the screen.
  2. Services: They handle background processing associated with an application.
  3. Broadcast Receivers: It handles the communication between Applications and Android Operating system
  4. Content Providers: They handle data and database management stuff.

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

5.How to get screen dimensions in pixels in Andorid Devices?

int screenHeight = getResources().getDisplayMetrics().heightPixels;

int screenWidth = getResources().getDisplayMetrics().widthPixels;

6.What is a Toast Notification?

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.

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

8.Which dialog boxes are supported by android?

Android supports 4 dialog boxes:

a.) AlertDialog: It supports 0 to 3 buttons and a list of selectable elements which includes radio buttons and check boxes.

b.) ProgressDialog: This dialog box is an extension of AlertDialog and supports adding buttons. It displays a progress wheel or bar.

c.) DatePickerDialog: The user can select the date using this dialog box.

d.) TimePickerDialog: The user can select the time using this dialog box.

9.What do containers hold?

– Containers hold objects and widgets in a specified arrangement.

– They can also hold labels, fields, buttons, or child containers.

10.Tell us something about activityCreator?

An activityCreator is the first step for creation of a new Android project.

It consists of a shell script that is used to create new file system structure required for writing codes in Android IDE.

Suggested Reading :

11.What is the difference between a class , a file and an activity in android?

Class – Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk

File – It is a block of arbitrary information, or resource for storing information. It can be of any type.

Activity – An activity is the equivalent of a 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.

12.What item are important in every Android Project ?

These are the essential items that are present each  time  an Android project is created:

– AndroidManifest.xml

– build.xml

– bin/

– src/

– res/

-assets/

13.Describe the SmsManager class in android.

SmsManager class is responsible for sending SMS from one emulator to another or device.

You cannot  instantiate this class directly; instead of , You can call the getDefault method static() to obtain an SmsManager object. Then send the SMS message using the

sendTextMessage() method:

SmsManagersms = SmsManager.getDefault();

sms.sendTextMessage(“5556”, null, “Hello from careerRide”, null, null);

sendTextMessage() method takes five argument.

– destinationAddress — Phone number of the recipient.

– scAddress — Service center address; you can use null also.

– sentIntent — Pending intent to invoke when the message is sent.

– text — Content of the SMS message that you like to send.

– deliveryIntent — Pending intent to invoke when the message has been delivered.

14.How to disable landscape mode in Android?

Open AndroidManifest.xml file and set following.

android:screenOrientation=”sensorPortait”

15.Enumerate the three key loops when monitoring an activity

– Entire lifetime  :  The activity happens between onCreate and onDestroy

– Visible lifetime  :  The activity happens between onStart and onStop

– Foreground lifetime : The activity happens between onResume and onPause

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

Useful Resources : Download Latest Android Topics for Interview Preparation

17.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– 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 copy tools on the device, browse the device and forward ports for debugging.

18.What do intent filters do?

– There can be more than one intents, depending on the services and activities that are going to use them and  each component wants to tell which intents they want to response to.

– Intent filters out the intents that these components are willing to respond to.

19.What is the difference between an implicit intent and explicit intent?

There are two types of Intent implicit and explicit intent, let see some more difference between them.

Implicit: Implicit intent is when you call system default intent like send email, send SMS, dial number.

For example,

Intent sendIntent = new Intent();

sendIntent.setAction(Intent.ACTION_SEND);

sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);

sendIntent.setType(“text/plain”)

startactivity(sendIntent);

Explicit: Explicit intent when you call you’re on application activity from one activity to another

For example, first activity to second activity:

Intent intent = new Intent(first.this, second.class);

startactivity(intent);

20.How can your application perform actions that are provided by other application e.g. sending email?

Intents are created to define an action that we want to perform and launches the appropriate activity from another application.

Intent intent = new Intent(Intent.ACTION_SEND);intent.putExtra(Intent.EXTRA_EMAIL, recipientArray);

startActivity(intent);

21.Name some exceptions in android?

  • Inflate Exception
  • OutOfResourceException
  • BadSurfaceTypeException
  • BadTokenException

22.What is the importance of XML-based layouts?

The Purpose of XML-based layouts provides a consistent and somewhat standard means of setting GUI definition format. Normally, layout details are placed in XML files while other items are placed in source files.

23.What is AVD?

AVD Stand for Android Virtual Device (emulator), The Android SDK includes a mobile device emulator – a virtual mobile device that runs on your computer.

24.Differentiate between LinearLayout, RelativeLayout, AbsoluteLayout.

LinearLayout arranges it’s children in a single row or single column one after the other.

A RelativeLayout arranges it’s children in positions relative to each other or relative to parent depending upon the LayoutParams defined for each view.

AbsoluteLayout needs the exact positions of the x and y coordinates of the view to position it. Though this is deprecated now.

25.Is it okay to change the name of an application after its deployment?

It is not recommended to change the application name after its deployment(final stage) because this action may break some functionality. For example, shortcuts will not work if you change application name.