Monday, October 5, 2009

working with layout

linear layout,relative layout,table layout,scroll layout

Working with basic Widget

Button, Image ,checkbox,radio button,label

creating your first activity in less java + more XML

creating your first activity in pure Java

Android Application development with eclipse IDE and ADT

Android Application development from the command prompt without eclipse IDE

pre requirement

setting ur environment variable fot android sdk tool directory.

finding out the available target

android list targets.



you need to use the Ant tool and setting the ant environment



variable



setting the JAVA_Home directory for ant








project creating command




android create project --target 1 --path
./myProject
--activity MyActivity --package
com.example.myproject







  • target is the "build target" for your application. It corresponds to an Android platform library (including any add-ons, such as Google APIs) that you would like to build your project against. To see a list of available targets and their corresponding IDs, execute: android list targets.


  • path is the location of your project directory. If the directory does not exist, it will be created for you.


  • activity is the name for your Activity class. This class file will be created for you inside <path_to_your_project>/src/<your_package_namespace_path>/.


  • package is the package namespace for your project, following the same rules as for packages in the Java programming language.





Output



Fullscreen capture 1142009 114735 AM.bmp



Fullscreen capture 1142009 114959 AM.bmp



The tool generates the following files and directories:




  • AndroidManifest.xml - The application manifest file, synced to the specified Activity class for the project.


  • build.xml - Build file for Ant.


  • default.properties - Properties for the build system. Do not modify this file.


  • build.properties - Customizable properties for the build system. You can edit this file to overried default build settings used by Ant.


  • src/your/package/namespace/ActivityName.java - The Activity class you specified during project creation.


  • bin/ - Output directory for the build script.


  • gen/ - Holds Ant-generated files, such as R.java.


  • libs/ - Holds private libraries.


  • res/ - Holds project resources.


  • src/ - Holds source code.


  • tests/ - Holds a duplicate of all-of-the-above, for testing purposes.






updating project






android update project --target
<targetID> --path path/to/your/project/






If you're upgrading a project from an older version of the Android SDK or want to create a new project from existing code, use the android update project command to update the project to the new development environment. You can also use this command to revise the build target of an existing project (with the --target option). The android tool will generate any files and folders (listed in the previous section) that are either missing or need to be updated, as needed for the Android project.






Building Your Application



there are two option




To build in debug mode:




  1. Open a command-line and navigate to the root of your project directory.


  2. Use Ant to compile your project in debug mode:
    ant debug



    This creates your Android application .apk file inside the project bin/ directory, named <your_DefaultActivity_name>-debug.apk. The file is already signed with the debug key.





Each time you change a source file or resource, you must run Ant again in order to package up the latest version of the application.







2.release mode





To build in release mode:




  1. Open a command-line and navigate to the root of your project directory.


  2. Use Ant to compile your project in release mode:
    ant release



    This creates your Android application .apk file inside the project bin/ directory, named <your_DefaultActivity_name>.apk.



    Note: The .apk file is unsigned at this point. You can't install it on an emulator or device until you sign it with your private key.






Running Your Application




we r running on a emulator( android emulator can have many instance with specific Android platform with specific device configuration settings )



AVD control the emulator shape and size(The platform and configuration is defined with an Android Virtual Device (AVD))




to check the list of avd




C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>android list avd
Available Android Virtual Devices:
Name: myand15
Path: C:\Documents and Settings\
NexGT0016\.android\avd\myand15.avd
Target: Android 1.5 (API level 3)
Skin: HVGA
Sdcard: 30M





to create new avd






C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>
android create avd --name newavd1.5 --target 2
Android 1.5 is a basic Android platform.
Do you wish to create a
custom hardware profile [no]
Created AVD 'newavd1.5' based on Android 1.5

C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>android list
avd
Available Android Virtual Devices:
Name: myand15
Path: C:\Documents and Settings\
NexGT0016\.android\avd\myand15.avd
Target: Android 1.5 (API level 3)
Skin: HVGA
Sdcard: 30M
---------
Name: newavd1.5
Path: C:\Documents and Settings\NexGT0016\
.android\avd\newavd1.5.avd
Target: Android 1.5 (API level 3)
Skin: HVGA





Launch an emulator






C:\Documents and Settings\NexGT0016\
gpworkcmd\mycmd>emulator
-avd newavd1.5
emulator: warning: opening audio output failed

emulator:emulator window was out of view
and was recentred





Fullscreen capture 1142009 124457 PM.bmp



emulator started



Install your application








C:\Documents and Settings\
NexGT0016>cd gpworkcmd

C:\Documents and Settings\
NexGT0016\gpworkcmd>cd mycmd

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd>cd bin

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd\bin>adb
install MyCMDActivity-debug.apk
45 KB/s (4389 bytes in 0.093s)
pkg: /data/local/tmp/MyCMDActivity-debug.apk
Success

C:\Documents and Settings\
NexGT0016\gpworkcmd\mycmd\bin>









Fullscreen capture 1142009 124944 PM.bmp







Fullscreen capture 1142009 125137 PM.bmp

Android application Building Block

What Androids Are Made Of



Activities


The building block of the user interface is the activity. You can think of an activity as being the
Android analogue for the window or dialog in a desktop application.
While it is possible for activities to not have a user interface, most likely your “headless”
code will be packaged in the form of content providers or services, like the following described.

Content Providers


Content providers provide a level of abstraction for any data stored on the device that is accessible
by multiple applications. The Android development model encourages you to make your
own data available to other applications, as well as your own—building a content provider lets
you do that, while maintaining complete control over how your data gets accessed.

Intents


Intents are system messages, running around the inside of the device, notifying applications of
various events, from hardware state changes (e.g., an SD card was inserted), to incoming data
(e.g., an SMS message arrived), to application events (e.g., your activity was launched from the
device’s main menu). Not only can you respond to intents, but you can create your own, to
launch other activities, or to let you know when specific situations arise (e.g., raise such-andso
intent when the user gets within 100 meters of this-and-such location).


Services


Activities, content providers, and intent receivers are all short-lived and can be shut down at
any time. Services, on the other hand, are designed to keep running, if needed, independent of
any activity. You might use a service for checking for updates to an RSS feed, or to play back
music even if the controlling activity is no longer operating.

Android application skeleton

What is inside the Android SDK

Android application development

 

Things you will required to walk with android

Download Android 1.0 SDK ,1.1, 1.5 or 1.6   download link

Download  java 5 or 6 download link

Download Eclipse 3.4 (Ganymede) or
Eclipse 3.5 (Galileo) IDE download link

Install the ADT Plug-in for Eclipse download link