Android Interview Questions



What is Android?
It is an open-sourced operating system that is used primarily on mobile devices, such as cell phones and tablets.
Android is a software stack for mobile devices that includes an operating system, middleware and key applications.
The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.



What are the Android Application Components?

There are four different types of application components which are the essential building blocks of an Android application. Each one is a unique building block that helps define application's overall behavior
They are
   i) Activity
   ii) Service
  iii) Content Provider
  iv) Broadcast Receiver

Activity - An activity represents a single screen with a user interface.

Service - A service is a component that does not provide a user interface but runs in the background to perform long-running operations or to perform work for remote processes.

Ex – music player app
When it starts playing, the user can open another applications and the music plays in the background.
There are two types of services in Android.
They are:
Unbound Services:
It is a type of service which is not bounded to any components. Once started, it will run in the background even after the component that started the service gets killed. It can be run in the background indefinitely and should stop by itself after the operation it is intended to carry out is completed.
Bound Services:
It is bound to other components and runs only till the component to which it is bounded runs.


Broadcast Receiver - A broadcast receiver is a component that responds to system-wide broadcast announcements
Ex: screen turn off, battery low, message received etc.,

Content provider  - Content providers provide a flexible way to make data available across applications.
Stores the data in the file system, SQLite database, on the web, or any other persistent storage location application can access. Through the content provider, other applications can query or even modify the data. They encapsulate the data, and provide mechanisms for defining data security

What is intent?
A class which describes what a caller desires to do. Three of the core components of an application — activities, services, and broadcast receivers are activated through messages called intents.

There are two types of Intents in Android:

Explicit Intents:
We specify which activity should get active on receiving the intent. These are usually used for application’s internal communications. They will specify a component which provides the exact class to be run.
Ex:
Intent ExplicitIntnt = new Intent (this, newact.class);
startActivity(ExplicitIntent);

Implicit intent:
Implicit intents do not declare the class name of the component to start, but instead declare an action to perform. The action specifies the thing you want to do, such as view, edit, send. Intents often also include data associated with the action, such as the address you want to view, or the email message you want to send.


Ex: 
Intent intent = new Intent (Intent.ACTION_VIEW, Uri. parse ("http://www.google.com"));

What is an intent filter?

 An intent filter declares the capabilities of its parent component i.e. what an activity or service can do and what types of broadcasts a receiver can handle.
Most of the contents of the filter are described by its <action>, <category>, and <data> subelements.

What is manifest?

The manifest presents essential information about the application to the Android system, which it must have before it can run any of the application's code.
 -All components are declared in this file.
 -Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts.
-Declare the minimum API Level required by the application
-Declare hardware and software features used or required by the application, such as a camera, bluetooth services, or a multitouch screen.

Describe the activity lifecycle?



Resume- Here, the activity is in the foreground and the user can interact with it.
Paused- the activity is partially obscured by another activity—the other activity that's in the foreground is semi-transparent or doesn't cover the entire screen. The paused activity does not receive user input and cannot execute any code.
Stopped- In this state, the activity is completely hidden and not visible to the user; it is considered to be in the background. While stopped, the activity instance and all its state information such as member variables are retained, but it cannot execute any code.


What are the versions of android?

Jelly Bean                   -     4.2, 4.1
Ice cream sandwich    -   4.0.3, 4.0
Honey Comb             -    3.0, 3.1, 3.2
Ginger Bread            -    2.3.3, 2.3.4
Froyo - 2.2
Éclair - 2.1
Donut     – 1.6
Cupcake – 1.5

Explain process hierarchy ?

Foreground process
A process that is required for what the user is currently doing. A process is considered to be in the foreground if any of the following conditions are true:
-It hosts an Activity that the user is interacting with (the Activity's onresume() method has been called).
-It hosts a Service that's bound to the activity that the user is interacting with.
-It hosts a Service that's running "in the foreground"—the service has called startForeground ().
-It hosts a Service that's executing one of its lifecycle callbacks (onCreate(), onStart(), or onDestroy()).
-It hosts a BroadcastReceiver that's executing its onReceive() method.
Generally, only a few foreground processes exist at any given time. They are killed only as a last resort—if memory is so low that they cannot all continue to run

Visible process
A process that doesn't have any foreground components, but still can affect what the user sees on screen.
A process is considered to be visible if either of the following conditions are true:
-It hosts an Activity that is not in the foreground, but is still visible to the user (it’s on Pause () method has been called.
-It hosts a Service that's bound to a visible (or foreground) activity.
A visible process is considered extremely important and will not be killed unless doing so is required to keep all foreground processes running.

Service process
A process that is running a service that has been started with the start Service () method and does not fall into either of the two higher categories. System keeps them running unless there's not enough memory to retain them along with all foreground and visible processes.

Background process
A process holding an activity that's not currently visible to the user (the activity's on Stop () method has been called). System can kill them at any time to reclaim memory for a foreground, visible, or service process.

Empty process
A process that doesn't hold any active application components. The system often kills these processes in order to balance overall system resources between process caches and the underlying kernel caches.


What Programming languages do Android support for application   development?Android applications support using Java Programming Language which is coded in Java and compiled using Android SDK.


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.

What are the different storage options in android?

Shared Preferences - Store private primitive data in key-value pairs.
Internal Storage - Store private data on the device memory.
External Storage - Store public data on the shared external storage.
SQLite Databases - Store structured data in a private database.
Network Connection - Store data on the web with your own network server.


What is APK format? Application package file (APK) is the file format that   holds all the program's code (such as .dex files), resources, assets, certificates, and manifest file. APK files are ZIP file formatted packages based on the JAR file format, with .apk file extension.


What is a Fragment?

A fragment is a part or portion of an activity. It is modular in a sense that you can move around or combine with other fragments in a single activity. Fragments are also reusable.


What are the dialog boxes that are supported in android? Explain.
Android supports 4 dialog boxes:

Alert Dialog : 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.
Progress Dialog: This dialog box displays a progress wheel or a progress bar.
DatePickerDialog: This dialog box is used for selecting a date by the user.

TimePicker Dialog: This dialog box is used for selecting time by the user.

What is android NDK?
The NDK (Native Development Kit) is a toolset that allows implementing parts of app using native-code languages such as C and C++.

What is an Adb?
Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator.

What is ADT?
ADT (Android Developer Tools) is a plug in for Eclipse that provides a suite of tools which provide GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface.



No comments:

Post a Comment