Tuesday, January 31, 2012

Android Interview Questions

What is meant by activity?

Activity provides a user interface for screens in our applications and able to interact with java codes to make our application components' design and its functions.

What is meant by Dalvik?

Dalvik is the virtual machine for android's operating systems.Each android applications runs with the help of Dalvik Virtual Machine.It runs classes complied by java language complier that have been transferred into .dex (Dalvik Executable) format so that Dalvik VM can executes files (Dalvik VM will executes files only in .dex format).

Describe Android Application Architecture?

Services - like Network Operation
Intent - To perform inter-communication between activities or services
Resource Externalization - such as strings and graphics
Notification signaling users - light,sound,icon,notification,dialog,etc.
Content Providers - They share data between applications.

What are the storage methods 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.

How will you record a phone call in Android?How to get a handle Audio Stream for a call in Android?

            Allows an application to monitor,modify or abort outgoing calls.

Describe a real time scenario where android can be used.

Imagine a situation that you are in a country where no one understand the language you speak and you cannot read or write.However if you have mobile phone with Android, the Google translator translates the data of one language inti another by using XMPP to transmit data.Like type in English and translates it according to that citizens and get the info you need.

What is APK format in Android?How to make an APK file?

APK termed as Application package file is a format that is used to distribute and install the application software for android and middleware on the the android operating systems. To make an APK file, first android is complied and than all of its part are grouped in one file termed as package.The package consists of entire program's code, resources,manifest file, etc.The file is saved with .apk extension

How the nine-patch image different from a regular bitmap? what is the difference between nine-patch image vs regular Bitmap Image?

It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device.The NinePatch class in Android allows drawing a bitmap in nine sections.The four corners are unscaled, the middle of the image is scaled in both axes,the four edges are scaled into one axis.

What is an DDMS?

Dalvik Debug Monitor Service, a GUI debugging application shipped with the SDK.It provides screen capture, log cat and process examination capabilities.

What is Drawable?

A complied visual resource that can be used as a background, title or other part of the screen. It is complied into an android.graphics.drawable subclass.

What is an adb?

Android Debug Bridge, a command-line debugging application shipped with the SDK. It provides tools to browse the device, copy tools on the device and forward ports for debugging.

What is a Content Provider?

It makes a specific set of the application's data available to other applications. The content provider extends the ContentProvider base class to implement a standard set of methods that enable other applications to retrieve and store data of the type it controls. However, applications do not call these methods directly. Rather they use a ContentResolver object and call its methods instead.

What are the exceptions in Android?

The following exceptions are mostly occur and that are supported by Android
InflateException : When an error conditions are occurred, this exception is thrown.
Surface.OutOfResourceException : When a surface is not created or resized, this exception is thrown.
SurfaceHolder.BadsurfaceTypeexception : This exception is thrown from the lockCanvas() method, when invoked on a surface whose is SURFACE_TYPE_PUSH_BUFFERS.
WindowManager.BadTokenException : This execption is thrown at the time of tying to add view an invalid WindowManager.LayoutParamstoken.

Why ListView not recommended to have Active components?

Clicking on the active text box will pop up the software keyboard but this will resize the list, removing focus from the clicked element.

What is meant by Manifest file in Android?

An XML file associated with each Android Application, it describes the component of the applications like activities, intent filter,services, broadcast receiver and content providers. It also describes which activity will host the application and describes about the permissions that need to be accessed by application for android protected APIs like for internet access, to access storage devices, Google maps, etc...,

What's the difference between class, file and activity in android?
Class - The Class file is complied from .java file. Android will use this .class file to produce the executable apk.
File - It is a block of resources, arbitrary information. It can be any file type.
Activity - An activity is the equivalent of a Frame/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.

What are the features of Android?
   Components can be reused and replaced by the application framework.
   Optimized DVM for mobile devices
   SQLite enables to store the data in a structured manner.
   Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies
  The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.

What is a service?
A service doesn’t have a visual user interface, but rather runs in the background for an indefinite period of time.
For example, a service might play background music as the user attends to other matters, or it might fetch data over the network or calculate
something and provide the result to activities that need it.
Each service extends the Service base class.
What is a Broadcast receivers?
A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.
For example, announcements that the timezone has changed, that the battery is low or that the user changed a language preference.
All receivers extend the BroadcastReceiver base class.
Broadcast receivers do not display a user interface. However, they may start an activity in response to the information they receive,
or they may use the NotificationManager to alert the user like(flashing the backlight, vibrating the device, playing a sound)

Key Features Need to Know in Android:

  • GUI layer in Android doesn't request data directly from the web but reads it from a local database
  • The service layer is used to periodically update the very same database
  • The GUI layer doesn't talk directly to the service layer (and vice versa) either
  • Risks of blocking the Main thread with e.g. heavy computation or lengthy operations like heave database queries, web access etc (blocking the main thread forces the system to throw an Application Not Responding exception for the given application, which will then "crash" and restart).
  • Regarding downloading of data, data sent over the Internet is not sent in a single chunk but rather in smaller packages, reading the first package isn't equal to have read all data sent by the server.
  • The background service, used for updating the database, is preferably killed by itself, not necessarily waiting for the system to kill it.

What's the difference between file, class and activity in android?
File - It is a block of arbitrary information, or resource for storing information. It can be of any type.
Class - Its a compiled form of .Java file . Android finally used this .class files to produce an executable apk
Activity - An activity is the equivalent of a Frame/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.
What are the dialog boxes that are supported in android? Explain.
Android supports 4 dialog boxes:

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

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

DatePickerDialog: This dialog box is used for selecting a date by the user.

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

What is needed to make a multiple choice list with a custom view for each row?

Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1". That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.

Explain IP datagram, Fragmentation and MTU ?

IP datagram can be used to describe a portion of IP data. Each IP datagram has set of fields arranged in an order. The order is specific which helps to decode and read the stream easily. IP datagram has fields like Version, header length, Type of service, Total length, checksum, flag, protocol, Time to live, Identification, source and destination ip address, padding, options and payload.
MTU:- Maximum Transmission Unit is the size of the largest packet that a communication protocol can pass. The size can be fixed by some standard or decided at the time of connection
Fragmentation is a process of breaking the IP packets into smaller pieces. Fragmentation is needed when the datagram is larger than the MTU. Each fragment becomes a datagram in itself and transmitted independently from source. When received by destination they are reassembled.

What is a Sticky Intent?

sendStickyBroadcast() performs a sendBroadcast (Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver (BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent).
One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
Is there anyway to determine if an Intent passed into a BroadcastReceiver's onReceive is the result of a sticky Boradcast Intent, or if it was just sent?

Example for sticky broadcast

When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.

No comments: