Begin at the Beginning

To work with anything in Android, you need a project. With ordinary Java, if you wanted, you could just write a program as a single file, compile it with javac, and run it with java, without any other support structures. Android is more complex, but to help keep it manageable Google has supplied tools to help create the project. If you are using an Android-enabled IDE, such as Eclipse with the Android plugin (available in the Android SDK), you can create a project inside of the IDE (select File >■ New >■ Project, then choose Android >■ Android Project).

If you are using tools that are not Android-enabled, you can use the activitycreator script, found in the tools/ directory in your SDK installation. Just pass activitycreator the package name of the activity you want to create and an - -out switch indicating where the project files should be generated. Here's an example:

activitycreator --out /path/to/my/project/dir \ com.commonsware.android.Now

You will wind up with a handful of pre-generated files, as described in Chapter 2. We'll be using these files for the rest of this chapter.

You can also download the project directories of the samples shown in this book in a ZIP file on the CommonsWare Web site1. These projects are ready for use; you do not need to run activitycreator on those unpacked samples.

0 0

Post a comment