- Getting Started / Hello World Basics
- Android Manifest File / Activities / Layouts
- Example Application: Building the Web View and Main Activity
You have most likely heard of Android by now. It is has numerous commercials and is Google's operating system for mobile phones. Android doesn't have as many applications for it yet as does the iPhone, but it’s closing in more and more everyday.
One of the main benefits of Android over iPhone is that Android can run on multiple devices from Samsung to Motorola. By being cross-platform, it opens up the door to all kinds of development opportunities for both manufacturers and developers alike.
The intent of this article is to get you started with the Android SDK and to learn some basics of the programming libraries that come with the SDK. The example project we will create is one that will allow our application to build simple web pages and display these pages in our app.
You can use a number of environments for Android development including command-line compilers like Maven or IDEs like Eclipse. I would highly recommend Eclipse for Android development as it makes life a lot easier in several ways. One way is that the Google Play market for deploying your apps requires a self-signed certificate (thus making your application unique), one for debugging and one for production. Eclipse makes it easy to generate the certs and/or change from debugging to production in no time at all. Eclipse also makes testing easier by loading an emulator and managing libraries for the SDK.
To get started, simply download the latest version of Eclipse if you do not have it, along with the Android SDK. To download the SDK, visit the Android developer portal. Click the Get SDK link and follow the simple instructions for downloading the libraries. You will also notice that there is an Eclipse plug-in for Android that allows you to create Android application projects.
Once you have the SDK installed and set the Eclipse Android Preferences to point to the SDK, you are ready to start your first Android application.
Hello World Basics
From Eclipse, select File > New > Project > Android Application Project to bring up the new project wizard. Enter the following information:
- Application name: The application name is what will appear in your app's title bar when running on the phone.
- Project name: This is the name of the project (i.e., helloworld).
- Package Name: The package name is the main application package, for example com.example.helloworld.
- Build SDK: Specify the build SDK and the minimum required SDK. This is the target build SDK for your application. It important to choose the latest version (i.e., API 16) so your app can run on these phones. If you specify an earlier API, your app will only run on that API or earlier. The API number corresponds to the Android operating version. For example, API 16 is for Android 4.1.
- Minimum Required SDK: Unlike Build SDK (target SDK), the Minimum SDK specifies the earliest API on which your app will run. For example, if you specify Android API 8, then your app will run on Android 2.2 (Froyo) and above (up to your Build SDK).
Next, leave the other fields on the following screens with their default values for creating the main activity and main layout file, which will be explained later. Once you click Finish to complete your project setup, Android will create the project directories. You will notice the typical Java 'src' folder for holding your app's code, but there is one that is specific to Android called 'res'. This folder will be explained shortly. First, it is important to understand the backbone of the Android application, and that would be the Android Manifest file.