Pages

Showing posts with label Android Tutorial. Show all posts
Showing posts with label Android Tutorial. Show all posts

Sunday, December 9, 2012

First day @ AnDevCon_IV

Last week I had a great time at AnDevCon_IV. Three days filled with Android, learned interesting stuff, met some smart people, connected with old buddies and shook hands with some famous personalities in Android world.

AnDevCon 4, a four day technical conference started on Dec 4 at Burlingame, California. They had hands on workshops on day 1, including Android Bootcamp, Embedded Android and Facebook apps for Android.

The second day was kicked off by a keynote by Ethan Evans, Director of App Developer Services, Amazon. He discussed the performance and impact of HTML5 apps and also mentioned how Amazon achieved the better performance by using both HTML5 and native code in their apps. He also explained blended HTML5 used in their App store hybrid architecture. "Updates without requiring Upgrades" was the most promising feature of HTML5, he said.

After his keynote, the actual classes began. It was a daunting task to choose between 70+ classes and many interesting topics were cross listed which made the selection even tougher. 'Hacking APKs for fun and profit (mostly fun)' sounded fun but I instead headed to "Dive into Android Fragments" session by Donn Felker. After he explained the basics of Fragments and fragment transactions, he talked about RoboGuice. It's a lightweight library that uses Google Guice library for dependency injection. It's not recommended for games or performance centric apps, but it does make code simpler and cleaner. He also talked about other open source projects -

  • Otto from Square - another dependency injection framework
  • ActionBarSherlock - extension to Android's support library to facilitate the use of ActionBar on all versions of Android
  • Viewpageindicator - adds pagination to Android code, especially useful when using multiple fragments or panes.
Android Bootstrap might be useful if you are planning to use above technologies, the project is built using many open source projects widely used in practice. 

Here is a link to Donn's Github project that he used to explain fragments.

Mike Wolfson presented two part series on Android Developer Tools. Google IO videos on this topics are much more informative so I will skip my notes on this session except for one piece of information.

HAXM - Intel® Hardware Accelerated Execution Manager  It's hardware assisted hypervisor, can greatly reduce the time required to boot an android image on an emulator. You need to download the driver for haxm and also Intel Atom image to use with the emulator. Currently it supports only ICS and JB images.
He also has a repo of all different types of AVDs, which can come handy during testing.

Marko Gargenta presented 'Architecting Android Apps' where he explained basic building blocks - activities, services, providers and receivers, as well as intents that glue them all together.

The post lunch sessions were the most engaging ones and were packed with useful information, so keeping myself awake was not hard.

Alex Gargenta presented 'Deep Dive into IPC/Binder Framework'. You should check out this video. He did a great job explaining binder concept, starting with the kernel level binder driver all the way up to application level code including discovery mechanisms, threading context, security implications etc.




I concluded Day 1 with "Mastering Android Touch system" session presented by Dave Smith. He provided in-depth look at how Android passes touch events between view hierarchies, why should you care about ACTION_DOWN even if you are interested only in ACTION_UP or ACTION_MOVE, what it means to handle a particular event etc. Code examples will make the theory simpler - here is the project he used.

Oh btw, driving on 101 sucks and it doesn't matter which direction you are travelling or if you are in hov lane or not, it sucks!

Saturday, September 1, 2012

Building Your First Android Application

Let's build our first application. Launch Eclipse. click New Android App Project  in the toolbar or select New Project under File menu, then select Android Project. Choose you Application name and package name. Uncheck "Create custom launcher icon" and click next
Next, select Blank Activity
And finally, name your activity. The Title is the Application Title shown in Android launcher screen. Click Finish. 

ADT will generate various folders and files and you will see the layout graphical editor oped for you. This is how your app will appear when launched on device. The ADT has already added the bare bone required to run your app on Android platform.
For this excercis, we will use an android virtual device to run our first app. An AVD is a device configuration for the Android emulator that allows you to model different devices. To create an AVD:
  1. Launch the Android Virtual Device Manager:
    1. In Eclipse, click Android Virtual Device Manager from the toolbar.
    2. From the command line, change directories to/tools/ and execute:
      ./android avd
  2. In the Android Virtual Device Manager panel, click New.
  3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a skin (HVGA is default).
  4. Click Create AVD.
  5. Select the new AVD from the Android Virtual Device Manager and click Start.
  6. After the emulator boots up, unlock the emulator screen, you will see the app running.
In next post, we will learn about application building blocks and we will also examine project directory structure to better understand the app components, Till then play with your Android AVD. It runs the entire android stack and also comes with standard stock apps such as Maps, Browser, Contacts etc. 

Tuesday, August 28, 2012

Getting Started with Android App Development

The beauty of Android development is that you are not restricted to any particular development environment. You can use any operating systems and any IDE you like. But since we will be writing Java code, Eclipse is a natural choice.

All you need are these 4 things

- Java SDK 6
- Eclipse IDE
- Android SDK
- Eclipse ADT plugin
- git (optional but recommended)

Get Java SDK


If you don't have Java SDK, getting it is simple. Download it from
http://www.java.com/getjava

Download Eclipse IDE


Download Eclipse Classic from http://www.eclipse.org/downloads/
If you are using Mac or Linux, and not sure if you are running 64bit or 32bit machine, inside Terminal run this command
$ uname -a
The output will tell you which eclipse binary you should download. Unzip and you have Eclipse.

Download Android SDK & Tools


Next step is to download Android SDK from
https://developer.android.com/sdk/index.html
Unzip the file you just downloaded. You should see android-sdk-mac folder. Copy it to a location where you want to download all other Android Development tools. Using terminal, navigate to tools folder inside android-sdk-mac and run android program
~/dev/android-dev/android-sdk-macosx/tools $ ./android  
This opens up Android SDK Manager. It shows you all installed components, the updates and also lists all available versions of Android SDK. This is where you will select what you need to download that includes, plain SDK, sample code, SDK source code, system images, Google APIs and also vendor specific components. If that's too much to take in, make sure you select for both Android 4.1 and Android 4.0.3
  • Documentation from Android SDK
  • SDK platform
  • Samples for SDK
  • ARM EABI system image
And under Tools category, select
  • Android SDK Tools
  • Android SDK platform-tools
And click install packages, next Accept all and let it finish.

The final step is to install Eclipse ADT plugin which makes Android development tools (mode on that later) part of the IDE for easy access. 

Download the ADT Plugin


  1. Start Eclipse, then select Help > Install New Software.
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
  4. Click OK.
    If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish.
    If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  8. When the installation completes, restart Eclipse.

Configure the ADT Plugin


After you've installed ADT and restarted Eclipse, you must specify the location of your Android SDK directory:
  1. Select Window > Preferences... to open the Preferences panel (on Mac OS X, select Eclipse > Preferences).
  2. Select Android from the left panel.
  3. You may see a dialog asking whether you want to send usage statistics to Google. If so, make your choice and clickProceed.
  4. For the SDK Location in the main panel, click Browse... and locate your downloaded Android SDK directory (such asandroid-sdk-windows).
  5. Click Apply, then OK.

Install Git


Git is an open source version control system. It works best for small projects as well as massive projects like Android platform itself. It will help you maintain different versions of your source code. In case you would like to download the Android source code, you will require git. It's very easy install.
Download it from below site and install it using package manager.
http://git-scm.com/

We will talk s more about git once we start developing actual applications. 

Next, we will talk about some Android Development Tools and will run our first Android app.