MY mENU


Monday 6 February 2012

Describe a real time scenario where android can be used?


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

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.

File,Class,Activity


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.

Components of Android


Components of Android are:


         1. Activities
         2. Services
         3. Broadcast Receivers
         4. Content Providers.


           Activity is the basic building block of every visible android application. It provides the means to render a UI. Every screen in an application is an activity by itself. Though they work together to present an application sequence, each activity is an independent entity.


          Service is another building block of android applications which does not provide a UI. It is a program that can run in the background for an indefinite period or perform various persistent actions such as playing music etc..


          Broadcast Receiver is yet another type of component that can receive and respond to any broadcast announcements. 


          Content Providers are a separate league of components that expose a specific set of data to applications.


          Intent is a class that contains several fields describing what a caller would like to do. Intents are messages that are passed between components. Intent is a bundle of information, a passive data structure that holds an abstract description of the operation to be performed.(or in the case of broadcasts, a description of an event that has happened and is being announced). 
 E.g. opening a PDF file is an intent, and the Adobe Reader is the suitable activity for this intent.


NOTE: Intents can be made to work exactly like API calls by using what are called explicit intents. 

URI's in Android

Android uses URI strings both for requesting data (e.g., a list of contacts) and for requesting actions (e.g., opening a Web page in a browser). Both are valid URI strings, but have different values. All requests for data must start with the string “content://”. Action strings are valid URIs that can be handled appropriately by applications on the device; for example, a URI starting with “http://” will be handled by the browser.

Theme in Android

Theme is A set of properties (text size, background color, and so on) bundled together to define various default display settings. Android provides a few standard themes, listed in R.style (starting with “Theme_”).

Difference Between URI and URL


URI
A URI identifies a resource either by location or name. More often than not, most of us use URIs that defines a location to a resource. However, a URI does not have to specify the location of a specific representation. Citing and example of a W3C URI for their home image, they use the following URI: http://www.w3.org/Icons/w3c_home. Note the absence of a file extension. The URI for the w3c_home image is still universally unique, but it does not specify the specific representation of the image (either a GIF, PNG, or JPG). The selection of the representation can be determined by the web server through HTTP content negotiation. The Apache HTTPD server has had excellent support for content negotiation for many years. Oddly, few sites take advantage of HTTP content negotiation. The W3C is one web application that makes heavy use of URIs and content negotiation.

URL
A URL is a URI but a URI is not a URL. A URL is a specialization of URI that defines the network location of a specific representation for a given resource. Taking the same W3C example, there are actually 2 representations available for the w3c_home resource:
http://www.w3.org/Icons/w3c_home.gif
http://www.w3.org/Icons/w3c_home.png
These URIs also define the file extension that indicates what content type is available at the URL. Through content negotiation, the web server will forward the user agent to the proper type, depending on the client̢۪s capabilities, when the URI http://www.w3.org/Icons/w3c_home is accessed.
More often than not, URI is the correct term to use when referring to the location of resources on the WWW.

Usage of 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). 



Android applications are written using the Java programming language. 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
Android only supports applications written using the Java programming language at this time.



NOTE: Google’s Dan Bornstein created Dalvik and named this virtual machine after an Icelandic fishing village where some of his ancestors lived.






Features Of Android

  • Application framework enabling reuse and replacement of components 
  • Dalvik virtual machine optimized for mobile devices 
  • Integrated browser based on the open source WebKit engine 
  • Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional) 
  • SQLite for structured data storage 
  • Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) 
  • GSM Telephony (hardware dependent) 
  • Bluetooth, EDGE, 3G, and WiFi (hardware dependent) 
  • Camera, GPS, compass, and accelerometer (hardware dependent) 
  • Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE.

Android Advantages

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

Difference between DVK and Jvm


Dalvik Virtual machine:
                     (DVM) is Register Architecture, designed to run on low memory, uses its own byte code and runs .Dex file (Dalvik Executable File)




Java Virtual Machine:
                        (JVM) is Stack Architecture, uses java byte code and runs .class file having JIT.
Java  source code is compiled by the Java compiler into .class files. Then the dx (dexer) tool, part of the Android SDK processes the .class files into a proprietary file format called DEX that contains Dalvik bytecode.

Difference between .class and .dex file format
                 ● In DEX all the classes of the application are packed into one file.
                 ● All the classes in the same DEX file share field, method, etc if they are same.
                 ● Classes from the same DEX file are loaded by the same class loader instance.


                     see Difference between DVM and JVM as Video

Introduction to Android


Android is an operating system for mobile devices that includes middleware and key applications, and uses a modified version of the Linux kernel. It was initially developed by Android Inc..It allows developers to write managed code in the Java language, controlling the device via Google-developed Java libraries…..
The Android SDK includes a comprehensive set of development tools . These include a debugger, libraries, a handset emulator (based on QEMU), documentation, sample code, and tutorials. Currently supported development platforms include x86-architecture computers running Linux (any modern desktop Linux distribution), Mac OS X 10.4.8 or later, Windows XP or Vista.


Android does not use established Java standards, i.e. Java SE and ME. This prevents compatibility among Java applications written for those platforms and those for the Android platform. Android only reuses the Java language syntax, but does not provide the full-class libraries and APIs bundled with Java SE or ME