Your task at hand is to create the Screen Brightness Toggle application, and because you're already an expert on setting up new Android applications, I'm not going to walk you through it step by step. If you need a brief refresher on how to create a new Android app in Eclipse, review Chapter 5.
If you still have files open from the Hello Android project in Chapter 5, you need to do some tidying up before starting on this new project. First, close all the files you already have open in Eclipse. You can do this by closing each file individually or by right-clicking the files and choosing Close All from the shortcut menu.
After you have closed all the files, you need to close the current project (Hello Android) in which you're working. In Eclipse, in the Package Explorer, right-click the Hello Android project and choose Close Project. By closing the project, you are telling Eclipse that you currently do not need to work with that project. Doing this frees resources that Eclipse uses to track the project state, and therefore speeds up your application.
You're now ready to create your new Screen Brightness Toggle application. Follow these steps to get started:
Setting | Value |
Application Name | Screen Brightness Toggle |
Project name | Screen Brightness Toggle |
Contents | Leave the default check box (Create New Project in Workspace) selected |
Build target | Android 3.1 |
Package name | com.dummies.android.screenbrightnesstoggle |
Create activity | MainActivity |
Min SDK Version | 11 |
Notice how you selected the build target of Android 3.1 and a Min SDK Version of 11. By making this selection, you told Android that your code can run on any device that is running at least a version code of 11 (Android 3.0). If you were to change this to version code 8, you would be saying that your app can run on any device running version 8 or higher. How do I know which version this app can run on? I tested it, before I wrote the book! When creating a new application, you should check to see whether it can run on older versions.
Your new Screen Brightness Toggle application appears in your Package Explorer, as shown in Figure 6-1.
However, if you receive a “The project cannot be built until build path errors are resolved” error, you can resolve it by right-clicking on the project and choosing Android ToolsFix Project Properties. Doing this realigns your project with the IDE workspace.
3.138.123.106