Saturday, 22 February 2014

Home

Vasanth Blog Home




Friday, 13 December 2013

First Android Application.

First Android Application.
In this tutorial we are going to create First Android Application. Before creating our First Android Application make sure that you have setup your Android Development Environment, if not refer tutorial Android - Environment Setup Tutorial. I also assume that you have a little bit working knowledge with Eclipse IDE.
1. Create Android Application.
  • Open your eclipse which has been configured with Android SDK.
  • Choose File -> New -> Project. In the New Project Wizard select Android Application Project and click Next.


  • New Android Application Wizard appears in which give your Application Name as "First Android Application" using wizard window as follows.


  • Next, follow the instructions provided and keep all other entries as default till the final step. Once your project is created successfully, you will have following project screen.



2. Anatomy of Android Application.
Before you run your app, you should be aware of a few directories and files in the Android project:


  1. AndroidManifest.xml
    Every Application must have an AndroidManifest.xml file in its root director. 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 code.
  2. src
    This contains all your Java files required for our application.
  3. res
    This contains all your resource required for our application. res contains other sub directories.
    • drawable
      Contains Images for our Application.
    • layout
      Contains all your layout files in which we will construct our Views.
    • values
      Contains Strings, Styles, Colours required for our application.
  4. gen
    It contains R.java file, it is a auto generated file that references all the resources found in your project. It acts as the bridge between our src and res.
  5. bin
    Once we Run our application bin gets generated which contains .apk file generated by our ADT.
3. Running the Android Application.
To Run our Android Application we require,
  • Android Emulator (or)
  • Android Mobile.
3.a) Running the Android Application Using Emulator.
To Run Android Application first we need to Create One Android Emulator (Android Virtual Device). Follow the steps to Create New AVD (Android Virtual Device).
  • Click Android Virtual Device Manager in Eclipse.


  • In Android Virtual Device Manager Wizard Click "NEW" to create New AVD (Android Virtual Device).


  • In Create New Android Virtual Device (AVD) Wizard give all required information and click OK to create New AVD.



    NOTE : On Windows, emulating RAM greater than 768M may fail depending on the system load. Try progressively smaller value of RAM if the emulator fails to launch.
  • We have successfully created AVD (Android Virtual Device).
    We are now ready to Run our first android application. Right Click on Our Project -> Run as -> Android Application. To Run our First Android Application.



    Android Emulator will launch with our First Android Application. Android Emulator will be slow and takes some time to launch.



    We have successfully run our First Android Application using Android Virtual Device (AVD).
3.b) Running the Android Application Using Android Mobile.
If you have a real Android-powered device, here's how you can install and run your app:
  • Plug in your device to your development machine with a USB cable. If you're developing on Windows, you might need to install the appropriate USB driver for your device. For help installing drivers, see the OEM USB Drivers document in Android Developer Website.
  • Enable USB debugging on your device.
    • On most devices running Android 3.2 or older, you can find the option under Settings > Applications > Development.
    • On Android 4.0 and newer, it's in Settings > Developer options.
      Note: On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings -> About phone and tap Build number seven times. Return to the previous screen to find Developer options.
    To Run our Application, . Right Click on Our Project -> Run as -> Android Application. Eclipse installs the app on your connected device and starts it.


References

http://developer.android.com/training/basics/firstapp/creating-project.html
http://developer.android.com/training/basics/firstapp/running-app.html
http://www.tutorialspoint.com/android/android_hello_world_example.htm

Saturday, 30 November 2013

Setting Up Android Environment.

Setting Up Android Environment.
1. Install Java Development Kit (JDK).
Download Java Development Kit (JDK) from Oracle Java website and install it in your machine.

What is JDK.
Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…
Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.
You need JDK, if at all you want to write your own programs, and to compile them. For running java programs, JRE is sufficient.

What is JRE.
JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.
Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system.

What is JVM.
As we all aware when we compile a Java file, output is not an "exe" but it’s a ".class" file. ".class" file consists of Java byte codes which are understandable by JVM. Java Virtual Machine interprets the byte code into the machine code depending upon the underlying operating system and hardware combination. It is responsible for all the things like garbage collection, array bounds checking, etc… JVM is platform dependent.

2. Setting up Android SDK.
We require three thing for Android Development.
  • Android SDK.
  • Eclipse IDE.
  • ADT (Android Development Tool).

Android SDK.
The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.

Eclipse IDE.
IDE standards for Integrated Development Environment. It's tool helps for developing application. IDE's are designed to maximize programmer productivity and helps the developer to write less number of code.

Android Development Tool (ADT).
ADT (Android Developer Tools) is a plugin for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access to many features that help you develop Android applications quickly.

2.1. Download SDK with ADT Bundle (If you don't have a Eclipse IDE).
If you're a new Android developer, we recommend you download the ADT Bundle to quickly start developing apps. It includes the essential Android SDK components and a version of the Eclipse IDE with built-in ADT (Android Developer Tools) to streamline your Android app development.
Get SDK and ADT Bundle from https://developer.android.com/sdk/index.html


With a single download, the ADT Bundle includes everything you need to begin developing apps:
  • Eclipse + ADT Plugin.
  • Android SDK Tools
  • Android Platform-tools.
  • The latest Android Platform.
  • The latest Android System image for the emulator.
With the single download we got Eclipse with ADT and Android SDK. We can double click on Eclipse and start developing application.

2.2. Setting Up Android SDK with Existing Eclipse IDE.
If you already have an IDE you want to use for Android app development, setting up a new SDK requires that you download the SDK Tools, then select additional Android SDK packages to install (such as the Android platform and system image). If you'll be using an existing version of Eclipse, then you can add the ADT plugin to it.

Download SDK.


Once Download has been completed, In the Android SDK folder we will have SDK Manager.exe run this executable file. We will get Android SDK Manager Window choose required Platforms and Tools that we need to install and click install.



Configure ADT to your Eclipse IDE.
In this step we are going to integrate Android SDK with Eclipse IDE, using the ADT (Android Development Tools) plugin.
  1. Open Eclipse and select Help -> Install New Software.
  2. Click ADD to add Android ADT Repository.
  3. In Add Repository window give Name as "Android Sdk"(you can give any name you want).
  4. And Give Location as "https://dl-ssl.google.com/android/eclipse/".




Select Developer Tools and Install it. Once it is complete then Android ADT Plugin has been configured to our eclipse.

Integrate Android SDK with Eclipse IDE using ADT.
After installing the ADT plugin, you have to define the location of the Android SDK in Android preferences in Eclipse:
  1. Select Window -> Preferences… to open the Preferences panel.
  2. Select Android from the left panel.
  3. For the SDK Location in the main panel, click Browse… and locate your downloaded SDK directory.
  4. Click Apply, then OK.



Android SDK and ADT has been integrated with our Eclipse IDE, hence we are ready to develop our First Android Application.


References

https://developer.android.com/sdk/index.html
http://stackoverflow.com/questions/11547458/what-is-differences-between-jvm-jdk-jre-openjdk
http://theopentutorials.com/tutorials/android/installing-android-sdk-and-eclipse-adt-plugin/

Sunday, 24 November 2013

Android Architecture

Android Architecture.

Android Architecture Diagram.



Android Architecture contains four layers.
  1. Linux Kernel.
  2. Libraries & Android Runtime.
  3. Application Framework.
  4. Application.

1. Linux Kernel.

The basic layer is the Linux kernel. The whole Android OS is built on top of the Linux Kernel with some further architectural changes made by Google. It is this Linux that interacts with the hardware and contains all the essential hardware drivers. Drivers are programs that control and communicate with the hardware. For example, consider the Bluetooth function. All devices has a Bluetooth hardware in it. Therefore the kernel must include a Bluetooth driver to communicate with the Bluetooth hardware. The Linux kernel also acts as an abstraction layer between the hardware and other software layers. Android uses the Linux for all its core functionality such as Memory management, process management, networking, security settings etc. As the Android is built on a most popular and proven foundation, it made the porting of Android to variety of hardware, a relatively painless task.


2. Libraries & Android Runtime.

  1. Libraries.
    Native Libraries mostly came from other open source project. Some of important Native Libraries are,

    WebKit : Library for Fast HTML Rendering.
    OpenGL : Library for Graphics.
    Media Codecs : Library offers support for major audio/video codecs.
    SQLite : Library for Database.

  2. Android Runtime.
    Android Runtime consists of Dalvik Virtual Machine and Core Java Libraries.

    1. Dalvik Virtual Machine.
      Dalvik VM is android implementation of Java VM. Dalvik is named after fisherman village in Iceland. It is developed by Dan Bornstein of Google. Unlike the JVM, the Dalvik Virtual Machine doesn’t run .class files, instead it runs .dex files. .dex files are built from .class file at the time of compilation and provides higher efficiency in low resource environments.

      Why Android replaces Java VM with Dalvik VM.
      Business Reason : Because Java is owned by Oracle so it cost Money.
      Technical Reason : Davik is optimized for mobile devices to reduce Battery and Memory Consumption and to increase CPU Capabilities.

      Key Dalvik Differences.
      • Register-based versus stack-based VM.
      • Dalvik runs .dex files.
      • More efficient and compact implementation.
      • Different set of Java libraries than JDK.

    2. Core Java Libraries.
      Android contains all Java SE libraries except AWT and Swing.


      In Standard Java, we compile our Java Code using JavaC Compiler and we get Class Files and we run our Class files on top of JVM.
      In Android, we compile our Java Code using JavaC Compiler and we get Class Files and we recompile Class Files using DEX Compiler and we get Dalvik Executable and we run Dalvik Executable on top of Dalvik VM.
      During APP Development we don't care about it because system takes care of all these things by itself.


3. Application Framework.

Application Framework is basically exposing capabilities of the Platform to Apps.
As a App Developer, we can use Application Framework to interact with system to get information or to save information and we can do much more things.

Important Blocks of Application Framework are.
Activity Manager : Manages the activity life cycle of application.
Content Providers : Manages the data sharing between application.
Telephony Manager : Manages all Voice. We use Telephony Manager if we want to access voice calls in our application.
Location Manager : Location Management, using GPS and Cell Tower.


4. Application.

Application are the top layer in the Android Architecture and this is where our applications are going to fit. Several standard application comes pre - installed with device, such as

  • SMS Client App.
  • Dialer
  • Web Browser.
  • Contact App.

Application format for Android is .apk. Dalvik Executable + Resources = APK


Dalvik Exe - Java Code that we write is complied into Dalvik Executable.
Resources : It is not Code, it is Image, Video, Xml, Strings etc.
Native Libs : Apps may or may not contains Native Libs. For example Angry Birds contains Physics Engine written in C.


References

http://en.wikipedia.org/wiki/Android_version_history
http://en.wikipedia.org/wiki/Android_version_history
http://developer.android.com/about/dashboards/index.html

Sunday, 10 November 2013

Introduction to Android

Introduction to Android

Android

Android is an operating system based on the Linux kernel, and designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Initially developed by Android, Inc., which Google backed financially and later bought in 2005, Android was unveiled in 2007 along with the founding of the Open Handset Alliance: a consortium of hardware, software, and telecommunication companies devoted to advancingopen standards for mobile devices. The first Android-powered phone was sold in October 2008.

Open Handset Alliance

Open Handset Alliance, a consortium of technology companies including Google, device manufacturers such as HTC, Sony and Samsung, wireless carriers such as Sprint Nextel and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments, unveiled itself, with a goal to develop open standards for mobile devices.

First Android Phone - HTC Dream




Android Versions
  • Android 1.0 (API level 1)
    Android 1.0, the first commercial version of the software, was released on 23 September 2008. The first commercially available Android device was th0e HTC Dream.
  • Android 1.1 (API level 2)
    On 9 February 2009, the Android 1.1 update was released, initially for the HTC Dream only. Android 1.1 was known as "Petit Four" internally, though this name was not used officially. The update resolved bugs, changed the Android API and added a number of features.
  • Android 1.5 Cupcake (API level 3)
    On 27 April 2009, the Android 1.5 update was released, based on Linux kernel 2.6.27. This was the first release to officially use a codename based on a dessert item ("Cupcake"), a theme which would be used for all releases henceforth. The update included several new features and UI amendments.
  • Android 1.6 Donut (API level 4)
    On 15 September 2009, the Android 1.6 SDK – dubbed Donut – was released, based on Linux kernel 2.6.29. Included in the update were numerous new features.
  • Android 2.0 Eclair (API level 5)
    On 26 October 2009, the Android 2.0 SDK – codenamed Eclair – was released, based on Linux kernel 2.6.29.
  • Android 2.0.1 Eclair (API level 6)
    On 3 December 2009, the Android 2.0.1 SDK was released, Minor API changes, bug fixes and framework behavioral changes.
  • Android 2.1 Eclair (API level 7)
    On 12 January 2010, the Android 2.1 SDK was released, Minor amendments to the API and bug fixes.
  • Android 2.2–2.2.3 Froyo (API level 8)
    On 20 May 2010, the SDK for Android 2.2 (Froyo, short for frozen yogurt) was released, based on Linux kernel 2.6.32.
  • Android 2.3–2.3.2 Gingerbread (API level 9)
    On 6 December 2010, the Android 2.3 (Gingerbread) SDK was released, based on Linux kernel 2.6.35.
  • Android 2.3.3–2.3.7 Gingerbread (API level 10)
    On 9 February 2011, the Android 2.3.3 SDK was released, Several improvements and API fixes.
  • Android 3.0 Honeycomb (API level 11)
    On 22 February 2011, the Android 3.0 (Honeycomb) SDK – the first tablet-only Android update – was released, based on Linux kernel 2.6.36. The first device featuring this version, the Motorola Xoom tablet, was released on 24 February 2011.
  • Android 3.1 Honeycomb (API level 12)
    On 10 May 2011, the Android 3.1 SDK was released, Minor improvements and bug fixes.
  • Android 3.2 Honeycomb (API level 13)
    15 July 2011, the Android 3.2 SDK was released, Most first- and second-generation Google TV-enabled devices utilize Honeycomb 3.2.
  • Android 4.0–4.0.2 Ice Cream Sandwich (API level 14)
    The SDK for Android 4.0.1 (Ice Cream Sandwich), based on Linux kernel 3.0.1, was publicly released on 19 October 2011. Google's Gabe Cohen stated that Android 4.0 was "theoretically compatible" with any Android 2.3.x device in production at that time. The source code for Android 4.0 became available on 14 November 2011. Ice Cream Sandwich was the last version to officially support Adobe Systems' Flash player.
  • Android 4.0.3–4.0.4 Ice Cream Sandwich (API level 15)
    On 16 December 2011, the Android 4.0.3 SDK was released, Minor improvement and bug fixes.
  • Android 4.1 Jelly Bean (API level 16)
    Google announced Android 4.1 (Jelly Bean) at the Google I/O conference on 27 June 2012. Based on Linux kernel 3.0.31, Jelly Bean was an incremental update with the primary aim of improving the functionality and performance of the user interface. The performance improvement involved "Project Butter", which uses touch anticipation, triple buffering, extended vsync timing and a fixed frame rate of 60 fps to create a fluid and "buttery-smooth" UI. Android 4.1 Jelly Bean was released to the Android Open Source Projecton 9 July 2012, and the Nexus 7 tablet, the first device to run Jelly Bean, was released on 13 July 2012.
  • Android 4.2 Jelly Bean (API level 17)
    Google was expected to announce Jelly Bean 4.2 at an event in New York City on 29 October 2012, but the event was cancelled due to Hurricane Sandy. Instead of rescheduling the live event, Google announced the new version with a press release, under the slogan "A new flavor of Jelly Bean". Jelly Bean 4.2 was based on Linux kernel 3.4.0, and debuted on Google's Nexus 4 (made by LG) and Nexus 10 (made bySamsung), which were released on 13 November 2012.
  • Android 4.3 Jelly Bean (API level 18)
    Google released Jelly Bean 4.3 under the slogan "An even sweeter Jelly Bean" on 24 July 2013 during an event in San Francisco called "Breakfast with Sundar Pichai". Most Nexus devices received the update within a week, although the 2nd generation Nexus 7 tablet was the first device to officially ship with it. A minor bugfixing update was released on 22 August 2013.
  • Android 4.4 KitKat (API level 19)
    Google announced Android 4.4 KitKat (named in collaboration with Nestlé and Hershey) on 3 September 2013. The release had long been expected to be numbered 5.0 and called 'Key Lime Pie'.[123] KitKat debuted on the Google's Nexus 5 made by LG.

Android Version Market Share as of November 2013




Version Codename API Distribution
2.2 Froyo 8 1.7%
2.3.3 - 2.3.7 Gingerbread 10 26.3%
3.2 Honeycomb 13 0.1%
4.0.3 - 4.0.4 Ice Cream Sandwich 15 19.8%
4.1.x Jelly Bean 16 37.3%
4.2.x 17 12.5%
4.3 18 2.3%


Android Market Share as of November 2013




References

http://en.wikipedia.org/wiki/Android_version_history
http://en.wikipedia.org/wiki/Android_version_history
http://developer.android.com/about/dashboards/index.html