Creating the Silent Mode Toggle Application

Create the new application by choosing File⇒New Project. Choose Android Project from the list, and then click the Next button. Use Table 4-1 for your project settings.

Table 4-1 Project Settings for Silent Mode Toggle

Setting

Value

Application Name

Silent Mode Toggle

Project name

Silent Mode Toggle

Contents

Leave the default selected (create new project in workspace)

Build target

Android 4.1

Package name

com.dummies.android.silentmodetoggle

Create activity

MainActivity

Min SDK Version

8 (2.2)

Click the Finish button. You should now have the Silent Mode Toggle application in your Package Explorer, as shown in Figure 4-1.

technicalstuff.eps If you receive an error that looks similar to this — “The project cannot be built until build path errors are resolved” — you can resolve it by right-clicking the project and choosing Android Tools⇒Fix Project Properties. This realigns your project with the IDE workspace.

Figure 4-1: The Silent Mode Toggle application in Eclipse.

9781118417454-fg0401.tif

tip.eps Notice how you set the build target to 4.1 and the minimum SDK to 2.2 (API level 8). What you have done is told Android that your code can run on any device that runs at least version code 8 (Android 2.2). If you were to change this to version code 16, you would be saying that your app can run on any device running version 16 (Android 4.1) or higher. When creating a new application, you should decide whether you want it to run on older versions.

tip.eps If you need a refresher on how to create a new Android app in Eclipse, see Chapter 3.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset