Thursday, March 3, 2011

Android vs. Apple: The 2011 cage match


Throughout 2010 there were escalating tensions between Google Android and Apple iOS, as the two platforms emerged as the rising superpowers in the mobile world. But, if you thought things were heated between them last year, then as the saying goes, you ain’t seen nothing yet. These two ecosystems are on course for a massive collision in 2011 and the stakes are about to get a lot higher.

The arrival of the iPhone on Verizon is a major incursion into what had previously become Android territory. Android 3.0 “Honeycomb” (the tablet OS) is about to unleash an army of Android tablets in a full frontal assault on the iPad. There is going to be blood, but as my colleague Larry Dignan notes, the carnage is likely going to have a greater impact on the other competitors in the mobile market more than on Apple and Google themselves.

To help evaluate the race between Android and iOS in 2011, I’d like to approach it from the perspective of where the two platforms are vulnerable. That will help give us an idea of where they might go after each other and where upstarts may try to challenge them.

Weak spots for iOS

For the iPhone and iPad the number one draw is ease of use. Your toddler and your grandmother (the one who is intimidated by computers) can both pick up one of these devices and figure out how to use it. As Jerry Pournelle says, with Apple products “everything is either very simple or it’s utterly impossible.” The utterly impossible side is where we find Apple’s first weak spot.

1. Software inflexibility: There is very little tweaking and customization allowed by iOS. You have to do it Apple’s way or else it’s probably not an option. These limits allow iOS products to function very well within the protected space carved out by Apple. However, if you have the need or desire to do something that is not within the boundaries Apple has set for iOS (and can’t create an app to handle it), then you’re out of luck.

2. Productivity limitations: Both the iPhone and iPad are far better devices for consuming information than creating it. Part of the problem is with the on-screen keyboard, which works magnificently for short bursts of data entry but is not something you want to use for writing an email or document of greater length. The operating system itself is not especially tailored for multi-tasking or work-focused tasks such as building presentations, editing files, and juggling several bits of information at once.

3. Fewer hardware choices: Some people prefer really big screens while other people like ultra-small and portable devices. Some want a high-resolution camera lens and all the multimedia bells and whistles in their mobile device, while others don’t need any of that stuff (and don’t want to pay for it) but want a really nice hardware keyboard so that they can do longer data entry more comfortably. With Apple products, you have very few choices. In fact, with both iPhone and iPad there are really only two choices to make when buying the product: storage and connectivity. You get to pick how much storage you want and you get to pick the wireless carrier on the iPhone or the Wi-Fi only model vs. the mobile broadband model on the iPad. That’s it.

Weak spots for Android

The best thing about Android is that its Open Handset Alliance includes some of the biggest and best vendors in the mobile world, including Samsung, Motorola, HTC, LG, Dell, Sony-Ericsson, and many more. The Android partners make devices in all shapes and sizes and in virtually every iteration you can imagine. That’s also part of the problem.

1. Ecosystem chaos: The Android operating system is open source and so hardware makers can take it and do almost anything they want with it. The only real carrot-and-stick that Google has is whether to allow the hardware makers the ability to include the Android Market for applications on their devices. And, frankly, Google has not used this as effectively as it could to keep vendors from doing bad things like launching with long-outdated versions of Android like the Dell Streak did and loading up the device with a bunch of uninstallable crapware like AT&T did with the HTC Aria and Verizon did with the Samsung Fascinate.

2. Wildly inconsistent experiences: One of the main consequences of the ecosystem melee is that there is not enough of a consistent experience across different Android devices. For example, nearly all of the hardware vendors put the Android menu buttons in a different order at the bottom of the screen, and many of them even use different types of button icons, further confusing users. Then there’s the issue of Android software updates. Google releases major updates to the Android OS at least twice a year. However, in 2010, the only device that got those updates right away was Google’s Nexus One, which runs the stock Android OS. All of the other Android devices have a vendor-supplied skin (which typically makes the devices worse instead of better) that runs on top of Android. The hardware vendors have to update their custom Android skins to make them compatible with the newest Android software and then submit it to the wireless carriers, who have to make sure it doesn’t conflict with any of their Android apps, and then it finally gets pushed to the consumer. The timing of these updates is very inconsistent across the Android ecosystem.

3. Leadership vacuum: A lot of these Android problems boil down to the fact that Google needs to show stronger leadership of its ecosystem. Even if it can’t ultimately force the hands of hardware vendors since Android is open source, it can use the Android Market as a bigger stick against gross violators and it can publicly suggest best practices that it would like to see Android vendors adopt in order to pressure (and occasionally inspire) the hardware makers and wireless carriers into better behavior.

How will it turn out?

In the smartphone market, you have to wonder how well these two will be able to market against each other to exploit their weaknesses. The two are fairly well solidified in people’s minds. Unless more people get sick of being locked into the iTunes ecosystem on iPhone (no sign of that yet) or get fed up with the crapware and delayed updates with Android (only a few instances where the masses have noticed), then the 2010 growth trajectory of both platforms will likely hold.

The game is a little more wide open in tablets. Companies like ASUS are targeting Apple’s weak spots in productivity and hardware choices. Hewlett-Packard could combine its long experience in tablet hardware with Palm’s webOS to create a tablet with much better multi-tasking and business features than Android and iOS. But, again, Apple has a big lead here and Google’s tablet OS that it showed off at CES looked very impressive and there are already a lot of big hardware vendors that have lined up to use it.

The bottom line is that both Android and iOS are going to be wildly successful in 2011 and continue to gobble up mobile marketshare. In most cases, it won’t come at the expense of each other, although we should expect Apple to initially steal some Android sales on Verizon and Android will eat away at some iPad sales when its first wave of tablets hit the ground in the spring.

Nevertheless, there will be a ton of new customers coming into the market in both smartphones and tablets in 2011. Look for Google and Apple to dominate most of the new sales in both of those markets. That will keep both Android and iOS on major growth trajectories. Android will have a lot more devices and a lot more companies pushing its devices, so it will ultimately grab greater market share in smartphones, although Apple is very competitive on price (unlike in the Mac vs. PC battles of 1980s and 1990s) so it won’t just be relegated to the high end of the market. It will take a much larger chunk of market share than it did in the PC wars.

And, in tablets, Apple is out to a huge lead with the surprising success of the iPad. Android and others will start to eat into that cushion in 2011, but Apple will still command a majority of that market by the end of the year.

What about Microsoft, HP, BlackBerry, and Nokia?

Unfortunately, it looks like all four of these behemoths are on the wrong side of history. These guys are all going to be reduced to challenger status in 2011. They’ll be on the outside looking in. Both Microsoft (with Windows Phone 7) and HP (with Palm webOS) could have snatched some of the momentum away from Apple and Google a year ago in the smartphone market, but they’re a little late now. Even though both have solid products, their timing is off and they have a lot of ground to make up in winning over software developers to their platforms.

As for BlackBerry and Nokia, they both have a large installed base of customers to draw on and build from, but it’s not going to be enough to stem their losses in 2011. They are both too far behind when it comes to product innovation. Oh sure, they will continue to hold on to nice chunks of old market share in some places, but both will likely continue their decline at accelerating rates in 2011.

Apple's strategy: active curation creates value... | ZDNet

Apple's strategy: active curation creates value... | ZDNet

Market strategies of both Android Market as well as Apple App Store.

Tuesday, March 1, 2011

Two Faces Of Android

The Two Faces of Android

Kevin Marks:
"The most remarkable thing about Android is that it is the first widely adopted Open Source client operating system. It's long been clear that Open Source is the best way to preserve infrastructural code from the vicissitudes of corporate and governmental volatility, but using it for client applications has so far not taken off as well. There has often been a separation between an open source underlying layer and a proprietary user experience that is built atop it.
Android does follow this pattern to some extent - the underlying OS code is fully Open Source under an Apache License, so anyone can bend it to their own uses, but in order to get the "with Google" logo on your device, you need to conform to Google's Compatibility Definition Document. That has changed over time; for example the 2.1 version specifies that your device MUST have a camera and 1.6 requires telephony.
If you do this, you might then get access to what I call the top half of Android - the closed source Google apps that integrate the device closely with their web services - Contacts, GMail, Talk, Android Market, Google Maps, Navigation, Listen, Earth, Places and so on. However, this requires an explicit partnership with Google.
a lot of the day-to day utility of an Android device is in the proprietary, partners-only layer - that you only get after doing a business development deal with Google of some kind. What we will start to see is alternatives for these Applications being developed. To some extent we're already seeing this from US carriers, but I think this year we'll see both an Open Source suite of apps to swap in many of these functions, and other proprietary offerings to compete with the Google upper half." (http://epeus.blogspot.com/2011/01/two-faces-of-android.html)

Criticism of the Openness of Android

"Android is proprietary, despite being marketed as open source. Android has a compatibility pledge, signed and kept behind closed doors. Android has no governance model, nor any indication there will be one. Android has no spec, and the license prohibits alternative implementations, as that’s not a use licensed by Google in the SDK license. Android is completely controlled by Google, and Google reserves the right to kill off competitors applications if they hurt Google financially, etc. It’s only as open as it is in Google’s financial interest to allow openness, by design.” (http://ianskerrett.wordpress.com/2007/11/13/what-does-android-mean-for-suns-openjdk/)

From the Wikipedia:
"Android has been criticized for not being all open-source software despite what was announced by Google. Parts of the SDK are proprietary and closed source and some believe this is so that Google can control the platform. The Android Software Development Kit License Agreement states that:
- 3.2 You agree that Google (or Google's licensors) own all legal right, title and interest in and to the SDK, including any intellectual property rights which subsist in the SDK. Use, reproduction and distribution of components of the SDK licensed under an open source software license are governed solely by the terms of that open source software license and not by this License Agreement. Until the SDK is released under an open source license, you may not extract the source code or create a derivative work of the SDK. [2]
However, Google has since announced that all parts of the OS will be released under the Apache License where applicable and under the GPL elsewhere. Google's applications that interact with Google's systems, such as their email service, are not open source.
Also, at least for now, software installed by users must be written in Java and will not have access to lower level device APIs.[41] This provides end-users with less control over their phone's functionality than other free and open source phone platforms, such as OpenMoko.
Another issue is related to Android's disregard of 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."

Sources:
The creation of the Dalvik virtual machine which is the basis of the Android platform, has also raised concerns that the first major fracturing of the Java platform may be in progress.
Dalibor Topic on the Android License: "There is a bunch of other rather objectionable stuff, but dear me, this is pretty bad as far as license agreements for pseudo-open-source software go." [3]

From LaForge:
"As many other people have been blogging and news sites have been reporting: The Android source code has been released. This is definitely good news. However, freedom-loving people already discover in blog posts that there's a remote kill switch by which Google can disable an already installed application and that some features are reserved to vendor-signed applications.
To me, those things are not a big surprise. As soon as you try to get in bed with the big operators, they will require this level of control. Android is not set out to be a truly open source mobile phone platform, but it's set out to be a sandbox environment for applications.
And even with all the android code out there, I bet almost (if not all) actual devices shipping with Android and manufactured by the big handset makers will have some kind of DRM scheme for the actual code: A bootloader that verifies that you did not modify the kernel, a kernel that ensures you do not run your own native applications.
Thus, Android so far was little more to me than yet-another-J2ME. Some sandbox virtual machine environment where people can write UI apps for. In other words: Nothing that gets me excited at all. I want a openness where I can touch and twist the bootloader, kernel, drivers, system-level software - and among other things, UI applications.
I actually think it's a bit of an insult if people think of Motorola's EZX or MAGX (and now Android) phones as "Linux phones". Because all the freedoms of Linux (writing native applications against native Linux APIs that Linux developers know and love, being able to do Linux [kernel] development) are stripped.
In the end, to what good is Linux in those devices? Definitely not to any benefit of the user. It's to the benefit of the handset maker, who can skip a pretty expensive Windows Mobile licensing fee. Oh and, yes, they get better memory management than on Symbian ;)
That's the brave new world. It makes me sick." (http://laforge.gnumonks.org/weblog/)

Thursday, February 24, 2011

Gemini - The Android Trojan

Android systems have been attacked before, but the Geinimi Trojan seems to take things to another level. Once it’s installed in the form of a game or app from a third-party app store, it starts giving out some relevant user information like the IMEI or ISMI number. Thankfully, the Lookout security app has listed out quite a few things for us.

The Trojan shows botnet-like capabilities by letting remote servers access user information and, in simple terms, let them control the affected user’s phone. Geinimi connects to remote servers that use one of the ten embedded domain names. Some of these subsets include www.widifu.com, www.udaore.com, www.frijd.com, www.islpast.com and www.piajesj.com.


Don't let this affect your precious Android handset

There’s some really sensitive information that’s been given out once Geinimi strikes. Here is what they do:
Send location coordinates (fine location)
Send device identifiers (IMEI and IMSI)
Download and prompt the user to install an app
Prompt the user to uninstall an app
Enumerate and send a list of installed apps to the server
The remote servers will only prompt users to install or uninstall apps, the user still has to confirm the installation or uninstallation.

If you’re using the Lookout security app (free or premium), be rest assured, your phone is protected. Otherwise, try not downloading apps from Chinese app stores. There’s a basic list of dos and don’ts below :
Only download applications from trusted sources, such as reputable application markets. Remember to look at the developer name, reviews, and star ratings.

Always check the permissions an app requests. Use common sense to ensure that the permissions an app requests match the features the app provides.

Be aware that unusual behavior on your phone could be a sign that your phone is infected. Unusual behaviors include: unknown applications being installed without your knowledge, SMS messages being automatically sent to unknown recipients, or phone calls automatically being placed without you initiating them.

Download a mobile security app for your phone that scans every app you download. Lookout users automatically receive protection against this Trojan.

- courtesy Google Android Developers Group

Tuesday, November 30, 2010

Android CLI Tools

Hello everyone, this is my second article on Android Application Development. This time I will be introducing you to the command line utilities that comes packaged with the Android SDK. All these utilities are extensively used to create an Android Application. When using an IDE(Integrated Development Environment) like Eclipse, the developer never realises about the existense of these utilities because IDE's provide abstraction between developer and implementation of the process to create an application package. We all being an open source enthusiasts and Linux users, we should know how to build an application from command line, and to know exactly what is going on behind the scenes. I will be introducing you to some tools that comes along with Android SDK. This will give you a better understanding of the process involved in creating an android application. This knowledge will also help you in debugging the application.

These are the tools that are packaged with the Android SDK :


In this folder there are many tools available but we will be looking at the below tools, as they are used most often. The tools we will be dealing with are:

  • adb

  • android

  • ddms

  • emulator

  • mksdcard

  • sqlite3

  • traceview

We will be looking each tool in detail in the following sections.

  • Adb:

      • adb stands for “Android Debug Bridge”. Its main functionality is to manage the state of the emulator instance which is running or the android based phone which is connected to the system.

      • Adb is based on a client – server mechanism where in “client” is the Android Emulator instance or the Android device connected and “server” is your development machine. Server communicates with the client through a daemon process which runs in the background of your development system.

      • Issuing commands to the android instances using adb:

        • adb server is running on your development machine and now we need to attach this server to a client. Here we can have multiple clients, like 2 emulator instances running simulteneously, 1 USB device plugged along the instances, etc. Therefore we need to find the number of clients connected to development machine. This is done by running the following command,

          $ adb devices

      • Now, when we know the number of clients, we can run a command directed specifically towards a particular client/instance. This can be done by running the following command:

                $ adb -s command

                $ adb -s emulator-5554 shell

            • serial-number: The name of the device that you see after issuing

              adb devices command under List of Devices column.

            • command can be any adb command like :

              • install <.apk file> : Installs an android application on the device

              • shell : presents you the adb client's console

              • logcat: displays all the log information on the system console

                To see all the other commands that you can use with adb can be found here: http://goo.gl/pQ0s

  • Android:

      • This is a very important tool in terms of developing an android application. It lets you do 3 things:

        • To create and delete Android Virtual Deveices (AVD / emulators).

          • When a new AVD/emulator instance is created, “android” creates a dedicated folder for your AVD with a mapping to the system image, userdata image, sd-card image and some other files required by AVD.

            Note: Each AVD does not contain a separate system image but it contains a mapping to it. Config.ini file maps the avd to system image based on the target of device(android-7(Eclair 2.1), android-8(Froyo 2.2)).

          • To create an AVD, there are some things we have to decide like the target of the device, this can be found by issuing this command:

$ android list targets

this shows the android targets supported by your development system.

          • Now once you have decided the target with which you want to create an AVD, we issue the following command to create an AVD:

$ android create avd -n myandy_2.2 -t 3

-n : Signifies the name of the AVD you want to specify.

-t : Signifies the “id” of the target with which the AVD needs to be created

Figure-4 Figure-5 Figure-6

Figure-4 shows you all the targets I have on my system and Figure-5 & 6 shows you the prompts that are asked when you create a new AVD for its hardware profile.

$ android list avd

Similarly if you want to delete an AVD then you can issue this command:

$ android delete avd -n myandy_2.2

        • To create and update android projects

          • Eclipse IDE creates a new Android Project in a very intuitive way but internally what it does is issue the following command:

$ android create project --target 3 \

--name HelloWorld \

--path ./Workspace/MyAndroidAppProject \

--activity HelloWorldActivity \

--package home.saket

Figure-7 Figure-8

        • Updating the android platform that you have on your development machine with the latest android releases, add-ons, etc. This can be done by launching the AVD Manager directly from the command line by issuing :

$ android

Figure-9

  • DDMS:

        It stands for “Dalvik Debug Monitoring Service”. It is the debugger tool which is shipped along with the android SDK. It provides a way to debug our application running on the device remotely on our development machine. It can be launched from the command line by issuing the following command:

        Note: It is assumed that you have the android tools directory set in your $PATH

$ ddms

Figure-10

This launches the debugger automatically attached to the running emulator instances.

In this debugger tool, you can view all the emulators attached as well as the processes running respective to the emulator instances on the left pane. On the right pane you can see some tabs for monitoring some emulator properties. We can see the “memory usage” of each of the applications running on the emulator, we can also see the CPU load, etc from the SysInfo tab. Similarly, we can also test an application by calling the emulator instance. It is done by entering the number in the “Incoming Number” field under Emulator Control tab.

Memory Usage Figure-11 Incoming Number Figure-12

In the same way we can also see the heap status of the device by causing Garbage collection of the device. It is done by following the below steps:

  • Select a process from the left pane

  • Under VM Heap, if it is written that “No Heap updates are available for this client” then we need to select Show Heap Updates button on top of left pane and then click the “Cause GC” button in VM Heap tab.

  • We will be able to see the heap update status showing the available memory in the device along with some extra information about the heap.

  • Emulator:

This tool is used to launch and control the emulator instance. An AVD created by the “Android” utility can be launched or stopped using the emulator utility. An AVD can be launched by issuing the follwing command:

$ emulator -avd

Ex: $ emulator -avd myandy_2.2

We can use emulator utility to control various hardware simulations of the emulator instance, like networking, media, etc. There are many options available to play around with the emulator utility. These options are also referred to as “startup options”.

General Syntax of using emulator utility:

emulator -avd

Example 1: When you run emulator instance by using

emulator -avd

OR

emulator @

you will not be able to see the logging information on the system terminal. Therefore, by starting the emulator instance with the startup option “-logcat” we will be able to see the initial logging that happens during the boot up of android OS.

Example 2: We can also open up a root shell on the emulator instance by using the foolwoing command:

emulator -avd -shell

Example 3: This startup option disables the animation of the android logo during boot.

emulator -avd -no-boot-anim

Networking in Emulator:

When an emulator instance is powered up, it always runs behind a virtual router/firewall and hence isolated from the development environment. All the address spaces that are handled by emulator instances are in the range of “10.0.2.0 – 10.0.2.99”

Note: To access the developement machine's localhost, it is by default set to 10.0.2.2.

Once the emulator instance is running, we can connect to the instance using a simple telnet connection.

$ telnet localhost

Ex: $ telnet localhost 5554

Type help on the android console and you will be presented with some commands as shown in the below figure.

Figure-13


Similarly, there are plenty of options available for the emulator, you can find all the options at http://goo.gl/Mmqh

  • Mksdcard:

          This tool lets you create an sdcard disk image which you can load it into the emulator. The file system created will be of the format FAT32.

          To create and load an sdcard file into an emlator instance we issue the following commands:

$ mksdcard -l

Ex: $mksdcard -l S 512M saket.img

$emulator @myandy_2.2 -sdcard saket.img

                      Figure-14

  • Sqlite3:

          This command is used to enter the sqlite database system. Using this command you can create, modify the databases present inside your emulator instance.

          To enter into the database of your android device, you need to enter the following commands:

$ emulator @myandy_2.2 -shell

# sqlite3

sqlite3> .help

Generally when you have a database based android application, your application database is stored in “/data/data//databases”.

          You can perform DDL, DML statements in exactly the same way as in SQL.

sqlite3> create table employee(

emp_id int,

emp_name varchar(20)

);

sqlite3> .tables

employee

  • Traceview:

          This tool is used to profile the application. To be able to use this utility, there are some requirements that your application should have. The application code has to have “Debug.startTracingMethod(String tracename)” method call at the beginning and “Debug.stopTracingMethod()” call at the end of the method to stop tracing. This method stores the tracing information onto an SDCard and hence your emulator instance should have an SDCard attached. The tracing methods writes a file at “/sdcard/.trace” and hence we need to give permissions to ou application to be able to write a file on SDCard. The permission is given in “AndroidManifest” as

          android.permission.WRITE_EXTERNAL_STORAGE” />”

          When application is run on the emulator, we need to pull the trace file from the emulator instance and feed it to “traceview” utility. This is done in the following way:

$ adb pull /sdcard/HelloWorld.trace /tmp

$ traceview /tmp/HelloWorld.trace

          Now, you will be presented with a traceview window as shown in Figure-16 below,

This GUI traceview is divided into 2 sections:

  • Timeline Section

  • Profile Section

Timeline Section shows you the execution time of each Thread in corresponding rows.

Profile Section shows you all the time that is spent by CPU inside a method with some statistics included in separate columns.

Some other tools that are used internally are

  • dx: This is used to convert a .class file to .dex file.

  • Monkey: This tool is used for stress testing of an android application. It issues random events on the application like touch, gesture, click events to test an android application.

    Lets run monkey on email application which comes packaged when we create a new emulator instance,

$ emulator @andy_2.2

$ adb shell monkey -p com.android.email -v 500

Monkey is actually a android device console tool, it is passed the application package name(com.android.email) and number of tests(500) that it has to test for application.

I hope you would have liked the article and this knowledge share would be helpful in your quest with Android. I will be back with some other interesting information on Android Application Development in the coming editions.Furthermore, we will discuss building advanced application on Android and for Android.



Sunday, July 25, 2010

Android Application Development

What is Android?

Android is a collection of softwares for mobile devices that includes an operating system, middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.

Android Features:

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

Android Architecture:



Android applications are written in the Java programming language. The compiled Java code — along with any data and resource files required by the application is bundled into an Android package, an archive file marked by an .apk suffix.

Sample Application:

The sample application that I am going to use is a Simple Interest Calculator that I had built when I started with Android Application Development. I intend to explain beginners about android application development using this application.

Environment Setup:

Android Application Development starts with setting up environment for android application by following the steps mentioned in the android developer site.

The steps below provide an overview of how to get started with the Android SDK.

1. Prepare your development computer

You may need to install the JDK (version 5 or 6 required) and Eclipse (version 3.4 or 3.5, needed only if you want develop using the ADT Plugin).

2. Download and install the SDK starter package

Select a starter package for android sdk and download it to your development computer. To install the SDK, simply unpack the starter package to a safe location and then add the location to your PATH(if windows).

3. Install the ADT Plugin for Eclipse

If you are developing in Eclipse, set up a remote update site at https://dl-ssl.google.com/android/eclipse/ under Help -> Install New Software -> Add. Install the Android Development Tools (ADT) Plugin, restart Eclipse, and set the "Android" preferences in Eclipse to point to the SDK install location.

Note: If the above mentioned link doesn't work then just replace https with http.

4. Add Android platforms and other components to your SDK

Use the Android SDK and AVD Manager, included in the SDK starter package, to add one or more Android platforms (for example, Android 2.0 or Android 2.2) and other components to your SDK. Preferably just download the latest of the lot. You can also download the documentation for the version of Android you are downloading.

To launch the Android SDK and AVD Manager on Windows, execute SDK Setup.exe, at the root of the SDK directory. On Linux, execute the android tool in the /tools/ folder which would be " /tools/ sudo sh android "

Once you setup thee environment for android application development you can start by creating a sample project by creating an Android Project using Eclipse IDE as shown in below figure:


The fields that are shown here have a specific meaning attached to it.
1. Project Name specifies the name of the project that a user can give.
2. Just check one of the android libraries from the list presented to you by the Eclipse IDE.
3. Application Name specifies the title that is shown when you run your application.
4. Package name field has to be at least 2 levels deep.
5. Activity name specifies the name of your class that is going to be created and this class will extend the Activity class from android library. We will cover activity class later in the tutorial.

When the new android project is created you get the following folder structure as shown below:




Lets now discuss the folder structure because I feel it would help you in segregating your resources for the application in a proper way.

1. src :
This folder holds all the java classes that you create.

2. res:
This folder stands for Resource, it holds all your images, layout files, and string value xml.

3. drawable:
There are 3 folders for storing images based on the resolution sizes of the screens of mobile phones.

4. layout:
This folder consists of a single xml file initially defining the layout configurations.

5. values:
This folder holds a xml file named strings.xml file. This file maps values of ID's with string values. This topic will be discussed later in the tutorial.

6. AndroidManifest.xml:
This is the main configuration file for the whole of android application. It defines the way your application will be launched, the number of activities present in your application, the permissions that your application has, etc, etc..

7. default.properties:
This file is generally used for localization purposes.

Now, lets start the tutorial with the main.xml file which configures the layout of our application.

Layout terms that will be used are very similar to Java SWING components.

1. LinearLayout:
A layout that arranges its children in a single row or column. It has some attributes like orientation which specifies whether the layout will be single row or column.

2. Button:
It specifies a single button.

3. EditText:
This corresponds to a editable textbox field where a user can enter data.

4. TextView:
This tag corresponds to a Label field.

Android offers 2 kinds of layout design, XML layout, UI layout which is provided by ADT. I prefer XML layout because I am used to it and UI layout development is a bit jerky as of now and needs a lot of improvement.

Using the above tags I have written the layout of this demo application in main.xml which you can refer from http://code.google.com/p/simpleinterestcalculator/

Now lets get to the java part of android application development.
Here I have created only one java class for performing an operation. As the application becomes complex we can have multiple java classes performing operations.

1. Activity:
Activity in android terms is nothing but a screen window. We extend our class with Activity because we need a single screen window for having a UI for the application and shown to the user. When you want to perform different actions or have multiple screens application then you need to have separate java classes extending Activity class for each of the screen windows.

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

When you create a new android project, these are the 3 lines of code that will be automatically generated by the Eclipse IDE for you.

1. onCreate() method is the method that gets invoked when your application starts.
2. It calls the super onCreate() method to set initial parameters of the screen window which is referred as Activity class.
3. setContentView(R.layout.main) initializes the screen layout with main.xml.

We have the layout set for our application. Now our job is to find a way to refer to the UI elements on java side. To accomplish this we have a method named findViewById(), this gets the UI element based on the ID that we assign to each UI component while designing the layout in main.xml.

Ex: messageBox = (Button)findViewById(R.id.box);

You can refer to the code from http://code.google.com/p/simpleinterestcalculator/. In this example :

1. We get the reference of Calculate button because we perform action only on click of the button.

2. We assign an OnClickListener() to the button which catches the event of CLICK of the button and makes the user override the onClick() method of the listener.

3. We perform the basic validations of the fields of the EditText elements for NULL value.

4. We use the wrapper class of Double to convert the string values to their actual Double values.

5. If any error occurs then we show the user a Toast message which is nothing but a display of a pop up message telling the user about the error.

6. If all the validations holds good then calculate the simple interest from the formula and display it in a Alert dialog box showing the calculated interest. Syntax that needs to be used to show the AlertDialog is:

AlertDialog.Builder alertbox = new AlertDialog.Builder(v.getContext());
// set the message to display
alertbox.setMessage("Simple Interest = "+si.toString());
// add a neutral button to the alert box and assign a click list alertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
// click listener on the alert box
public void onClick(DialogInterface arg0, int arg1) {
// the button was clicked
Toast.makeText(getApplicationContext(), "Thank You !!!!", Toast.LENGTH_LONG).show();
}
});

// show it
alertbox.show();

I have also created a screen cast of this application which you can refer and get to know how the application works.

This was a very basic overview of Android Application Development using a basic example but "There is a lot more to Android That Meets The Eye", for more information on android and demo applications you can refer to the following links:

References:


Groups:


Tuesday, June 29, 2010

Some Of My Android Demo Applications

1. My First Android Demo Application



2. Date & Time



3. Basic Twitter UI




4. My Blog Seen From Android



5. Touch Me Not!!!



6. Simple Interest Calculator