Thursday, February 16, 2012

Android Interview Questions?

How Many types of Intent in Android.

There are 2 types of intents that Android understands.
1. Explicit Intent
2. Implicit Intent
In an Explicit intent, you actually specify the activity that is required to respond to the intent. In other words, you explicitly designate the target component. This is typically used for application internal messages.
In an Implicit intent (the main power of the android design), you just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, you do not declare the target component and hence is typically used for activating components of other applications seamlessly
Note: Here for simplicity sake I tell an activity responds to an intent, it could as well be other types of components.

Describe the APK format.
The APK file is compressed the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.

What is an action?
A description of something that an Intent sender desires.A description of something that an Intent sender wants done. An action is a string value assigned to an Intent. Action strings can be defined by Android or by a third-party developer. For example, android.intent.action.VIEW for a Web URL, or com.example.rumbler.SHAKE_PHONE for a custom application to vibrate the phone.

What is activity?
A single screen in an application, with supporting Java code.

What is Intent filter?
Activities and intent receivers include one or more filters in their manifest to describe what kinds of intents or messages they can handle or want to receive. An intent filter lists a set of requirements, such as data type, action requested, and URI format, that the Intent or message must fulfill. For Activities, Android searches for the Activity with the most closely matching valid match between the Intent and the activity filter. For messages, Android will forward a message to all receivers with matching intent filters.


What is .dex extension?
Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applicationswritten in the Java programming language.


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.

What is intent?
A class (Intent) describes what a caller desires to do. The caller sends this intent to Android's intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF file is an intent, and the Adobe Reader is the suitable activity for this intent.

How is nine-patch image different from a regular bitmap?
It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.

What languages does Android support for application development?
Android applications are written using the Java programming language.

What is a resource?
A user-supplied XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.

What is an action?
A description of something that an Intent sender desires.An action can be performed by intent, service and using broadcasting.

How will you record a phone call in Android? How to get a handle on Audio Stream for a call in Android?
Permissions.PROCESS_OUTGOING_CALLS: Allows an application to monitor, modify, or abort outgoing calls.

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 is a Sticky Intent?
sendStickyBroadcast() performs a sendBroadcast (Intent) that is "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.


Common Tricky questions
Remember that the GUI layer doesn't request data directly from the web; data is always loaded from a local database.
The service layer periodically updates the local database.
What is the risk in blocking the Main thread when performing a lengthy operation such as web access or heavy computation? Application_Not_Responding exception will be thrown which will crash and restart the application.
Why is List View 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.

if we SMS interception for system signalling. Is there a mechanism for an app to respond and stop the signaling chain? Is there security around that so that one vendor canâ„¢t hijack a message and respond to it?
Thereâ„¢s a mechanism where an application can register to receive a message with a certain signature and prevent others from getting it.

Q. Does Android support the Bluetooth serial port profile?
A. Yes.

Q. Can an application be started on powerup?
A. Yes.

Q.How to Remove Desktop icons and Widgets
A. Press and Hold the icon or widget. The phone will vibrate and on the bottom of the phone you will see anoption to remove. While still holding the icon or widget drag it to the remove button. Once remove turns red drop the item and it is gon

What is android?
Android is a stack of software for mobile devices which has 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 language’s byte code which later transforms into .dex format files.

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.

Why to use Android?
Android is useful because:
    It is simple and powerful SDK
    Licensing, Distribution or Development fee is not required
    Easy to Import third party Java library
    Supporting platforms are – Linux, Mac Os, Windows

Describe Android Application Architecture.
Android Application Architecture has the following components:
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 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.


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.



Explain about the exceptions of Android.
The following are the exceptions 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 exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.


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)

What is a content provider?
A content provider 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 is intent?
A class (Intent) describes what a caller desires to do. The caller sends this intent to Android’s intent resolver, which finds the most suitable activity for the intent.

How is nine-patch image different from a regular bitmap?
It is a resizable bitmap resource that can be used for backgrounds or other images on the device. The NinePatch class permits drawing a bitmap in nine sections. The four corners are unscaled; the four edges are scaled in one axis, and the middle is scaled in both axes.



What Virtual Machine Android runs on?
Dalvik virtual machine

Android Latest Version?
Android 3.0

How do you define the user interface?
XML Format is the best.


How to start a browser instance with some url ?
Intent intent = new Intent(Intent.ACTION_VIEW);
Uri u = Uri.parse("http://google.com");
intent.setData(u);
startActivity(intent);

Function called when return from a sub activity.
protected void onActivityResult(int requestCode, int resultCode, String data, Bundle extras) {
}

How to retrieve the device IMEI Number
TelephonyManager mTelephonyMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
imei = mTelephonyMgr.getDeviceId();


How to call a subactivity?
Intent intent = new Intent(this, SubActivity.class);
//to pass data
addintent.putExtra(name, value);
startActivityForResult(intent, int);


What is a Layout resource?
An XML file that describes the layout of an Activity screen



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


What are the advantages of android?

The following are the advantages of Android:
* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.
* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized
* Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in Android.





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.

Why is open platform good for the mobile operators?
An open platform would foster faster innovation, multiple software versions, better customisation options, lower costs, which would bring down the overall service and handset costs while boosting sales.

How to Translate in Android?
The Google translator translates the data of one language into another language by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens.

1 comment:

  1. nice work...all the questions are important and very helpful.
    You can do more practice with android interview questions @ http://skillgun.com

    ReplyDelete