Friday 11 October 2013

Android Interview Questions and Answers(Top most question asked in 2015 & 2016)

                                                           

 QuesWhat 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 byte code which later transforms into .dex format files.
Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

Ques. What are the key components of Android Architecture?


Mainly Android Architecture have 4 key components:

  •  Linux Kernel
  •  Libraries
  •  Android Framework
  •  Android Applications


Ques. What are the advantages of Android?  






















  • Multitasking – Yups, Android phones can run many applications, it means you can browse, Facebook while listened to the song.



















  • Ease of Notification – Any SMS, Email, or even the latest articles from an RSS Reader, there will always be a notification on the Home Screen Android phone, do not miss the LED indicator is blinking, so you will not miss a single SMS, Email or even Misscall .



















  • Easy access to thousands of applications via the Google Android Android App Market – When you love to  install applications or games, through Google’s Android App Market, Agan can download applications for free. There are many thousands of applications and games that are ready for download on Android phones You.



















  • Phone options are diverse – Talk Android phone, it will feel ‘different’ than the IOS, if the IOS is limited to the iPhone from Apple, then Android is available on mobile phones from various manufacturers, from Sony Ericsson, Motorola, HTC to Samsung. And each handset manufacturer also presents an Android phone in the style of each, such as Motorola with its Motoblur, Sony Ericsson with its Timescape. So You can freely choose the Android phone in accordance with the ‘brand’ favorite.



















  • Can install a modified ROM – not satisfied with the standard view of Android, do not worry there are many custom ROM that can be used in your mobile phones Android .



















  • Widget – absolutely right, with the widgets on the homescreen, You can easily access a variety of settings quickly and easily.



















  • Google Maniac – If you are a loyal user of Google services ranging from Gmail to Google Reader Android phone has integrated with Google services, so you can quickly check e-mail from Gmail.

  • - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf





















  • Multitasking – Yups, Android phones can run many applications, it means you can browse, Facebook while listened to the song.



















  • Ease of Notification – Any SMS, Email, or even the latest articles from an RSS Reader, there will always be a notification on the Home Screen Android phone, do not miss the LED indicator is blinking, so you will not miss a single SMS, Email or even Misscall .



















  • Easy access to thousands of applications via the Google Android Android App Market – When you love to  install applications or games, through Google’s Android App Market, Agan can download applications for free. There are many thousands of applications and games that are ready for download on Android phones You.



















  • Phone options are diverse – Talk Android phone, it will feel ‘different’ than the IOS, if the IOS is limited to the iPhone from Apple, then Android is available on mobile phones from various manufacturers, from Sony Ericsson, Motorola, HTC to Samsung. And each handset manufacturer also presents an Android phone in the style of each, such as Motorola with its Motoblur, Sony Ericsson with its Timescape. So You can freely choose the Android phone in accordance with the ‘brand’ favorite.



















  • Can install a modified ROM – not satisfied with the standard view of Android, do not worry there are many custom ROM that can be used in your mobile phones Android .



















  • Widget – absolutely right, with the widgets on the homescreen, You can easily access a variety of settings quickly and easily.



















  • Google Maniac – If you are a loyal user of Google services ranging from Gmail to Google Reader Android phone has integrated with Google services, so you can quickly check e-mail from Gmail.

  • - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf
    Android phones can run many applications, it means you can browse, Facebook while listened to the song. - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf
    • Multitasking: With Android, you can quickly and seamlessly switch between apps and pick up whatever you were doing. Juggling multiple tasks at once on a mobile device has never been easier. 
    • It have simple and powerful SDK. Also allows multitasking.
    • Licensing, Distribution or Development fee is not required.
    • Easy to Import third party Java library.
    • Supporting platforms are – Linux, Mac Os, Windows.
    • Innovative products like the location-aware services, location of a nearby convenience store etc., are some of the additive facilities in 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. 
    • 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.            
    • There's no other software quite like Android. Google engineered Android, and Google’s own apps run best on it. And with millions of apps, games, songs, and videos on Google Play, Android is great for fun, and for getting things done.                     
    Multitasking – Yups, Android phones can run many applications, it means you can browse, Facebook while listened to the song. - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf

    Ques. What is the disadvantages of Android? 


    Given that Android is an open-source platform, and the fact that different Android operating systems have been released on different mobile devices, there’s no clear cut policy to how applications can adapt with various OS versions and upgrades. One app that runs on this particular version of Android OS may or may not run on another version. Another disadvantage is that since mobile devices such as phones and tabs come in different sizes and forms, it poses a challenge for developers to create apps that can adjust correctly to the right screen size and other varying features and specs. 

    Ques. What is activity?  

    An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI.

    Ques. What are the exceptions in Android?

    • InflateException : This exception is thrown by an inflater on error conditions.                    
    • Surface.OutOfResourceException: When a surface is not created or re-sized, 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.

    Ques. What are the different methods of the Activity life cycle?

    Here are Seven main methods:

    • void onCreate()
    • void onStart()
    • void onRestart()
    • void onResume()
    • void onPause()
    • void onStop()
    • void onDestroy()  

    QuesDoes Android support the Bluetooth serial port profile?


    Yes.

    Ques. What dialog boxes are supported in android?


    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.

    Ques. What is 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.

    Ques. What is .apk extension?


    The extension for an Android package file, which typically contains all of the files related to a single Android application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files.A project is compiled into a single .apk file.

    QuesWhat 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 applications written in the Java programming language.

    Ques. Explain the Architecture of Android ?



    Ques. What is a service? 


    A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding <Service>declaration in its package's AndroidManifest.xml. Services can be started with Context.startService()and Context.bindService().    
    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.

    Ques. Describe a real time scenario where android can be used? 


    Lets take a situation that you are in a country where no one understands the language you speak and you can not read or write. However, you have mobile phone with you.With a mobile phone with 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.

    QuesWhat is intent?


    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 startSerrvice to communicate with a background Service.
    An Intent provides a facility for performing late run time binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

    Ques.What is an Implicit Intent?


    In an implicit intent, the main power of the android design, we just declare an intent and leave it to the platform to find an activity that can respond to the intent. Here, we do not declare the target component and hence is typically used for activating components of other applications seamlessly. 

    Ques. What is an Explicit Intent?


    In an explicit intent, we actually specify the activity that is required to respond to the intent. In other words, we explicitly designate the target component. This is typically used for application internal messages.
      

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


    Ques:  What is an Android Manifest file? 


    Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. Among other things, the manifest does the following:

    • It names the Java package for the application. The package name serves as a unique identifier for the application.
    • It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.
    • It determines which processes will host application components.
    • It declares which permissions the application must have in order to access protected parts of the API and interact with other applications.
    • It also declares the permissions that others are required to have in order to interact with the application's components.
    • It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published.
    • It declares the minimum level of the Android API that the application requires.
    • It lists the libraries that the application must be linked against.

    Ques. What language does Android support for application development?


    Android applications are written using the Java programming language


    QuesHow to Remove Desktop icons and Widgets


    Press and Hold the icon or widget. The phone will vibrate and on the bottom of the phone you will see an option 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 gone.

    QuesWhat is the Guardian app for Android? 


    The Guardian app for Android delivers all the best content from guardian.co.uk to your phone or tablet. Read the latest news, sport, comment and reviews, watch video, listen to broadcast and browse stunning picture galleries while on the move.

    Ques. What is Mono for Android? 


    Mono for Android is a software development kit that allows developers to use the C# language to create mobile applications for Android based devices.Mono for Android exposes two sets of APIs, the core .NET APIs that C# developers are familiar with as well as a C# binding to Android's native APIs exposed through the Mono.Android.* namespace.You can use Mono for Android to develop applications that are distributed through the Android Application Stores or to deploy software to your personal hardware or the Android simulator.


    Ques.What is included in Mono for Android?


    Mono for Android consists of the core Mono runtime, the Mono for Android bindings to the native Android APIs, a Visual Studio 2010 plugin to develop Android applications and an SDK that contains the tools to build, debug and deploy your applications. Our Visual Studio 2010 plugin allows developers to use Visual Studio 2010 to develop, debug and deploy their applications to an Android simulator, an Android device, or the Android Application Store.



    QuesWhat do I need to develop Mono for Android applications? 


    Mono for Android on Windows provides a plugin for VisualStudio 2010 Professional or better. We also support Mono for Android development using MonoDevelop on Windows for users that do not own a copy of Visual Studio 2010 Professional or better.Mono for Android on Mac developers can use MonoDevelop.On all platforms, Mono for Android requires the Android SDK (which requires Java JDK).

    Ques. Are the Android releases available in a ROM? 


    No, Android is not yet available in a ROM format.Currently Android is installed by using a clean SD Card,and booted from there.It is booted by running a special application called 'Haret.exe' residing on your SD Card which will terminate the Windows kernel and boot into Linux/Android.It can't easily be run from ROM because:
    (a) it's too experimental to risk putting in ROM and then killing a device.
    (b) WinMo does some hardware initialization that isn't documented, but is needed before Android can run.

    Ques. How do I turn off, or reboot Android? 


    In earlier releases, you had to pull the battery or press the reset button, in newer releases, you can hold down the 'end call' button and see a menu.

    Ques. What is context in android? 


    Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. It allows access to application-specific resources and classes, as well as up-calls for application-level operations such as launching activities, broadcasting and receiving intents, etc.

    Ques. What is Notification in android? 


    A class that represents how a persistent notification is to be presented to the user using the NotificationManager. The Notification.Builder has been added to make it easier to construct Notifications.

    Ques. What is AsyncTask in android?  


    AsyncTask enables proper and easy use of the UI thread. This class allows to perform background operations and publish results on the UI thread without having to manipulate threads and/or handlers.An asynchronous task is defined by a computation that runs on a background thread and whose result is published on the UI thread. An asynchronous task is defined by 3 generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.

    Ques. Does android support jar applications? 


    You can't install jar files on Andriod devices but you can include jar as library in your application. 

    Ques. What is localization and how to achieve? 


    Localization is a way of representing the products in different languages. Android is an operating system which runs in many regions, so to reach different users localization is a must. Localization in Android can be achieved by incorporating different languages in the application which you are using. To do this knowledge of Java, XML elements, Activity lifecycle and general principles of internationalization and localization are required.  

    Ques. What are the different Storage Methods in android? 


    Android provides many options for storage of persistent data. It provides the solution according to your need. The storage's  which have been provided in Android are as follows:- 

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


    Ques. What is activity life cyle in android?  



    Activities in the system are managed as an activity stack. When a new activity is started, it is placed on the top of the stack and becomes the running activity -- the previous activity always remains below it in the stack, and will not come to the foreground again until the new activity exits.An activity has essentially four states:
    • If an activity in the foreground of the screen (at the top of the stack), it is active or running.
    • If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.
    • If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.
    • If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state.
    The following diagram shows the important state  of an Activity.  





                                                                      







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



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



    Ques. What is a Toast Notification? 




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


    Ques. What is a Content Provider?  


    Content Providers are the only way to share data across Android applications. They store and retrieve data thus making it accessible to all. Content Providers give a uniform interface to access the data. Android platform provides default implementations of content providers for data types like audio, video, images, contact information etc.  
    Content providers manage access to a structured set of data. They encapsulate the data, and provide mechanisms for defining data security. Content providers are the standard interface that connects data in one process with code running in another process.   

    Ques. What is the Open Handset Alliance? 


    The OHA is a consortium of 84 technology and mobile companies that have joined hands to accelerate innovation in mobile technology and at the same time offer the end users a better, cost-effective and richer mobile experience. Members of this include Google, HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas Instruments, Samsung, LG, T-Mobile, Nvidia. The OHA was started on 5 November 2007 by Google and 34 other companies. Android is the main software of the alliance.     

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

    Ques. What is ANR? 


    ANR is stand for Application Not Responding. This is actually a dialog that appears to the user whenever an application have been unresponsive for a long period of time.   

    See ANR msg:                              

    Ques. 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 runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients.
    • A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device.
    • A daemon, which runs as a background process on each emulator or device instance.
    You can find the adb tool in <sdk>/platform-tools/.

    It provides a wide array of debugging features including:


    • port-forwarding services
    • screen capture
    • thread and heap information
    • network traffic tracking
    • incoming call and SMS spoofing
    • simulating network state, speed, and latency
    • location data spoofing


    Ques. What is the importance of settings permissions in app development? 


    Permissions allow certain restrictions to be imposed primarily to protect data and code. Without these, codes could be compromised, resulting to defects in functionality.
    Additional finer-grained security features are provided through a "permission" mechanism that enforces restrictions on the specific operations that a particular process can perform, and per-URI permissions for granting ad-hoc access to specific pieces of data. 

    Ques. What is the proper way of setting up an Android-powered device for app development? 


    The following are steps to be followed prior to actual application development in an Android-powered device:
    Declare your application as “debug-gable” in your Android Manifest.
    Turn on “USB Debugging” on your device.
    Set up your system to detect your device.     

    Ques. What is a Fragment? 

    A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).
    A fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle. For example, when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all fragments. 

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

    Ques. Is it possible to use or add a fragment without using a user interface? 


    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. 


    Ques. What is Dalvik Virtual Machine? 


    The name of Android's virtual machine. The Dalvik VM is an interpreter-only virtual machine that executes files in the Dalvik Executable (.dex) format, a format that is optimized for efficient storage and memory-mappable execution. The virtual machine is register-based, and it can run classes compiled by a Java language compiler that have been transformed into its native format using the included "dx" tool. The VM runs on top of Posix-compliant operating systems, which it relies on for underlying functionality (such as threading and low level memory management). The Dalvik core class library is intended to provide a familiar development base for those used to programming with Java Standard Edition, but it is geared specifically to the needs of a small mobile device.     


    Ques. What is Android Runtime? 


    Android includes a set of core libraries that provides most of the functionality available in the core libraries of the Java programming language. Every Android application runs in its own process, with its own instance of the Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently. The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.     




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



    Ques. What is AVD in  Android?   




    An Android Virtual Device (AVD) is an emulator configuration that lets you model an actual device by defining hardware and software options to be emulated by the Android Emulator.
    You can create as many AVDs as you need, based on the types of device you want to model. To thoroughly test your application, you should create an AVD for each general device configuration (for example, different screen sizes and platform versions) with which your application is compatible and test your application on each one.


    An AVD consists of:




    • A hardware profile: Defines the hardware features of the virtual device. For example, you can define whether the device has a camera, whether it uses a physical QWERTY keyboard or a dialing pad, how much memory it has, and so on.

    • A mapping to a system image: You can define what version of the Android platform will run on the virtual device. You can choose a version of the standard Android platform or the system image packaged with an SDK add-on.

    • Other options: You can specify the emulator skin you want to use with the AVD, which lets you control the screen dimensions, appearance, and so on. You can also specify the emulated SD card to use with the AVD.
    • A dedicated storage area on your development machine: the device's user data (installed applications, settings, and so on) and emulated SD card are stored in this area. 

    Ques. 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 inter-process communication (IPC). On Android, one process cannot normally access the memory of another process. So to talk, they need to decompose their objects into primitives that the operating system can understand, and Marshall the objects across that boundary for you. The code to do that marshaling is tedious to write, so Android handles it for you with AIDL. 

    Ques. What data types are supported by AIDL? 


    AIDL supports following data types:
    • string
    • List
    • Map
    • charSequence 
    • All primitive types in the Java programming language (such as int, long, char, boolean, and so on)

    Ques. What is the difference between Activities from Services?


    An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI. But A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Activities can be closed, or terminated anytime the user wishes. On the other hand, services are designed to run behind the scenes, and can act independently. Most services run continuously, regardless of whether there are certain or no activities being executed. 


    Ques. What is the importance of Android in the 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.


    Ques. There are four Java classes related to the use of sensors on the Android. List them and explain a bit about each.


    The four Java classes related to the use of sensors on the Android are : 

    Sensor: Provides methods to identify which capabilities are available for a specific sensor.
    SensorManager: Provides methods for registering sensor event listeners and calibrating sensors.
    SensorEvent: Provides raw sensor data, including information regarding accuracy.
    SensorEventListener: Interface that defines callback methods that will receive sensor event notifications.


    Learn more.



    Ques. Describe three common use of an Intent in Android.


    Common use of Intent include:
    • To start an activity: You can start a new instance of an Activity by passing an Intent to startActivity() method.
    • To start a service: You can start a service to perform a one-time operation (such as download a file) by passing an Intent to startService().
    • To deliver a broadcast: You can deliver a broadcast to other apps by passing an Intent to sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().


    Ques. What is a ContentProvider and what is it typically used for?


    A ContentProvider manages access to a structured set of data. It encapsulates the data and provide mechanisms for defining data security. ContentProvider is the standard interface that connects data in one process with code running in another process.

    Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications. For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don't need to share data amongst multiple applications you can use a database directly via SQLiteDatabase.   

    When you want to access data in a content provider, you use the ContentResolver object in your application's Context to communicate with the provider as a client. The ContentResolver object communicates with the provider object, an instance of a class that implements ContentProvider. The provider object receives data requests from clients, performs the requested action, and returns the results.




    QuesThe last callback in the lifecycle of an activity is onDestroy(). The system calls this method on your activity as the final signal that your activity instance is being completely removed from the system memory. Mostly, the system will call onPause() and onStop() before calling onDestroy(). Describe a scenario, where onPause() and onStop() would not be invoked.


    onPause() and onStop() will not be invoked if finish() is called from within the onCreate() method. This might occur, for example, if you detect an error during onCreate() and call finish() as a result. In such a case, though, any cleanup you expected to be done in onPause() and onStop() will not be executed.
    Although onDestroy() is the last callback in the lifecycle of an activity, it is worth mentioning that this callback may not always be called and should not be relied upon to destroy resources. It is better have the resources created in onStart() and onResume(), and have them destroyed in onStop() and onPause, respectively.



    Ques.  Taking a scenario  where you are starting a service in an Activity as follows:



    Intent my_service = new Intent(context, MyService.class);             
    startService(my_service);
    here MyService accesses a remote server via an Internet connection.
    If the Activity is showing an animation that indicates some kind of progress, what issue might you encounter and how could you address it?



    Getting the Responses from a remote service via the Internet can often take some time, either due to networking latencies, or load on the remote server, or the amount of time it takes for the remote service to process and respond to the request.
    As a result, if such a delay occurs, the animation in the activity (and even worse, the entire UI thread) could be blocked and could appear to the user to be “frozen” while the client waits for a response from the service. This is because the service is started on the main application thread (or UI thread) in the Activity.

    The problem can  be avoided by relegating any such remote requests to a background thread or, when feasible, using an an asynchronous response mechanism.



    Ques. What is the relationship between the life cycle of an AsyncTask and an Activity? What problems can this result in? How can these problems be avoided?




    An AsyncTask is not tied to the life cycle of the Activity that contains it. So, for example, if you start an AsyncTask inside an Activity and the user rotates the device, the Activity will be destroyed (and a new Activity instance will be created) but the AsyncTask will not die but instead goes on living until it completes.
    Then, when the AsyncTask does complete, rather than updating the UI of the new Activity, it updates the former instance of the Activity.This can lead to an Exception (of the type java.lang.IllegalArgumentException: View not attached to window manager if you use, for instance, findViewById to retrieve a view inside the Activity).
    There’s also the potential for this to result in a memory leak since the AsyncTask maintains a reference to the Activty, which prevents the Activity from being garbage collected as long as the AsyncTask remains alive.
    For these reasons, using AsyncTasks for long-running background tasks is generally a bad idea . Rather, for long-running background tasks, a different mechanism (such as a service) should be employed.

    Learn More : AsyncTask and Activity


    Ques. What is the difference between a fragment and an activity? Explain a bit about both.


    An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows.

    A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).

    Learn More : Activity and Fragment



    QuesWhat are the 'launch mode' ? Explain two mechanisms by which they can be defined? What specific types of launch modes are supported in android system?


    Launch modes allow you to define how a new instance of an activity is associated with the current task. You can define different launch modes in two ways:


    • Manifest file. When declaring an activity in a manifest file, you can specify how the activity should associate with tasks when it starts. Supported values include:
      • Standard (default). Creates a new instance of the activity in the task from which it was started and route the intent to it.
      • SingleTop. If an instance of the activity already exists at the top of the current task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity.
      • SingleTask. Creates a new task and instantiates the activity at the root of the new task. However, if an instance of the activity already exists in a separate task, the system instead routes the intent to the existing instance through a call to its onNewIntent() method. Only one instance of the activity can exist at a time.
      • SingleTop. This is almost the same as singleTask, but has the activity itself always as the unique member of its stack.
    • Intent flags. Calls to startActivity() can include a flag in the Intent that declares if and how the new activity should be associated with the current task. Supported values include:
      • FLAG_ACTIVITY_NEW_TASK. Same as singleTask value in Manifest file (see above).
      • FLAG_ACTIVITY_SINGLE_TOP. Same as singleTop value in Manifest file (see above).
      • FLAG_ACTIVITY_CLEAR_TOP. If the activity being started is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it are destroyed and this intent is delivered to the resumed instance of the activity (now on top), through onNewIntent().




    Ques. What is difference between Serializable and Parcelable interface ? Which is best approach in Android ?


    Serializable is a standard Java interface. You simply mark a class Serializable by implementing the interface, and Java will automatically serialize it in certain situations.
    Parcelable is an Android specific interface where you implement the serialization yourself. It was created to be far more efficient than Serializable, and to get around some problems with the default Java serialization scheme.

    Difference:
    1. Parcelable is faster than serializable interface.
    2. Parcelable interface takes more time for implemetation compared to serializable interface.
    3. serializable interface is easier to implement.
    4. serializable interface create a lot of temporary objects and cause quite a bit of garbage collection.
    5. Parcelable array can be pass via Intent in android.























  • Multitasking – Yups, Android phones can run many applications, it means you can browse, Facebook while listened to the song.



















  • Ease of Notification – Any SMS, Email, or even the latest articles from an RSS Reader, there will always be a notification on the Home Screen Android phone, do not miss the LED indicator is blinking, so you will not miss a single SMS, Email or even Misscall .



















  • Easy access to thousands of applications via the Google Android Android App Market – When you love to  install applications or games, through Google’s Android App Market, Agan can download applications for free. There are many thousands of applications and games that are ready for download on Android phones You.



















  • Phone options are diverse – Talk Android phone, it will feel ‘different’ than the IOS, if the IOS is limited to the iPhone from Apple, then Android is available on mobile phones from various manufacturers, from Sony Ericsson, Motorola, HTC to Samsung. And each handset manufacturer also presents an Android phone in the style of each, such as Motorola with its Motoblur, Sony Ericsson with its Timescape. So You can freely choose the Android phone in accordance with the ‘brand’ favorite.



















  • Can install a modified ROM – not satisfied with the standard view of Android, do not worry there are many custom ROM that can be used in your mobile phones Android .



















  • Widget – absolutely right, with the widgets on the homescreen, You can easily access a variety of settings quickly and easily.



















  • Google Maniac – If you are a loyal user of Google services ranging from Gmail to Google Reader Android phone has integrated with Google services, so you can quickly check e-mail from Gmail.

  • - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf





















  • Multitasking – Yups, Android phones can run many applications, it means you can browse, Facebook while listened to the song.



















  • Ease of Notification – Any SMS, Email, or even the latest articles from an RSS Reader, there will always be a notification on the Home Screen Android phone, do not miss the LED indicator is blinking, so you will not miss a single SMS, Email or even Misscall .



















  • Easy access to thousands of applications via the Google Android Android App Market – When you love to  install applications or games, through Google’s Android App Market, Agan can download applications for free. There are many thousands of applications and games that are ready for download on Android phones You.



















  • Phone options are diverse – Talk Android phone, it will feel ‘different’ than the IOS, if the IOS is limited to the iPhone from Apple, then Android is available on mobile phones from various manufacturers, from Sony Ericsson, Motorola, HTC to Samsung. And each handset manufacturer also presents an Android phone in the style of each, such as Motorola with its Motoblur, Sony Ericsson with its Timescape. So You can freely choose the Android phone in accordance with the ‘brand’ favorite.



















  • Can install a modified ROM – not satisfied with the standard view of Android, do not worry there are many custom ROM that can be used in your mobile phones Android .



















  • Widget – absolutely right, with the widgets on the homescreen, You can easily access a variety of settings quickly and easily.



















  • Google Maniac – If you are a loyal user of Google services ranging from Gmail to Google Reader Android phone has integrated with Google services, so you can quickly check e-mail from Gmail.

  • - See more at: http://mobilecon.info/advantages-and-disadvantages-android-mobile-phone.html#sthash.DGvKKrUC.dpuf