Showing posts with label advance android interview question. Show all posts
Showing posts with label advance android interview question. Show all posts

Tuesday, 10 December 2013

Android Process

Android Process Discription


Anddroid Process:

When an application component starts and the application does not have any other components running, the Android system starts a new Linux process for the application with a single thread of execution.
The manifest entry for each type of component element—, , , and—supports an android:process attribute that can specify a process in which that component should run.

Process lifecycle

The Android system tries to maintain an application process for as long as possible, but eventually needs to remove old processes to reclaim memory for new or more important processes. rocesses with the lowest importance are eliminated first, then those with the next lowest importance, and so on

1.    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:
o    It hosts an Activity that the user is interacting with (the Activity's onResume() method has been called).
o    It hosts a Service that's bound to the activity that the user is interacting with.
o    It hosts a Service that's running "in the foreground"—the service has called startForeground().
o    It hosts a Service that's executing one of its lifecycle callbacks (onCreate()onStart(), oronDestroy()).
o    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. Generally, at that point, the device has reached a memory paging state, so killing some foreground processes is required to keep the user interface responsive.

2.    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:
o    It hosts an Activity that is not in the foreground, but is still visible to the user (its onPause() method has been called). This might occur, for example, if the foreground activity started a dialog, which allows the previous activity to be seen behind it.
o    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.

3.    Service process

A process that is running a service that has been started with the startService() method and does not fall into either of the two higher categories. Although service processes are not directly tied to anything the user sees, they are generally doing things that the user cares about (such as playing music in the background or downloading data on the network), so the system keeps them running unless there's not enough memory to retain them along with all foreground and visible processes.

4.    Background process

A process holding an activity that's not currently visible to the user (the activity's onStop() method has been called). These processes have no direct impact on the user experience, and the system can kill them at any time to reclaim memory for a foreground, visible, or service process. Usually there are many background processes running, so they are kept in an LRU (least recently used) list to ensure that the process with the activity that was most recently seen by the user is the last to be killed. If an activity implements its lifecycle methods correctly, and saves its current state, killing its process will not have a visible effect on the user experience, because when the user navigates back to the activity, the activity restores all of its visible state. See the Activities document for information about saving and restoring state.

5.    Empty process

A process that doesn't hold any active application components. The only reason to keep this kind of process alive is for caching purposes, to improve startup time the next time a component needs to run in it. The system often kills these processes in order to balance overall system resources between process caches and the underlying kernel caches

Android Interview Question

Android Interview question for Advance level

1.What are the Different Kinds of Context?

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


2.When does ANR occur?

Ans:
      
 application responsiveness is monitored by the Activity Manager and Window Manager system services. Android will display the ANR dialog for a particular application when it detects one of the following conditions:
·         No response to an input event (such as key press or screen touch events) within 5 seconds.
·         BroadcastReceiver hasn't finished executing within 10 seconds.

3. How to Avoid ANR


Android applications normally run entirely on a single thread by default the "UI thread" or "main thread"). This means anything your application is doing in the UI thread that takes a long time to complete can trigger the ANR dialog because your application is not giving itself a chance to handle the input event or intent broadcasts.

The most effecive way to create a worker thread for longer operations is with the AsyncTask class. Simply extend AsyncTask and implement the doInBackground() method to perform the work. To post progress changes to the user, you can call publishProgress(), which invokes the onProgressUpdate() callback method. From your implementation of onProgressUpdate() (which runs on the UI thread), you can notify the user.



4. What is the TTL (Time to Live)? Why is it required?

Ans:
Time to live is what dictates how long it will be until your computer refreshes its DNS related information. For example, the IP address your domain name points to or where your MX records are directing email.

5. Is android supports Multitouch ?

Ans:
       yes
Some Core Gesture Set that support by Android.
  1. Touch
  2. Long Press 
  3. Swipe
  4. Drag
  5. Double Touch
  6. Pinch open
  7. pinch close

6. What are  Component of Android application?

 
Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, calledintents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced

 7. What is Intent Objects?

An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity). Principally,

 8. What does ADT stand for?

Ans :
       Android Development Tool.
     
 

9. Android Log.v(), Log.d(), Log.i(), Log.w(), Log.e(), Log.h(), Log.wtf() - When to use each one?


Ans:
we use the Log.v() Log.d() Log.i() Log.w() and Log.e() methods.

The order in terms of verbosity, from least to most is ERROR, WARN, INFO, DEBUG, VERBOSE. Verbose should never be compiled into an application except during development. Debug logs are compiled in but stripped at runtime. Error, warning and info logs are always kept.

10.  What is AAPT? 

AAPT is short for Android Asset Packaging Tool. This tool provides developers with the ability to deal with zip-compatible archives, which includes creating, extracting as well as viewing its contents.

Keep Reading continue

Saturday, 21 September 2013

Why Android Created

  • Software development
  • Run on very small electronic devices
  •  Full phone software stack including applications
  •  Android is open
  •  Android is free
  • Developer can make and customize there own mobile applications

Today's Pageviews