Creating the Screen Brightness Toggle

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:

  1. Create the new application by choosing FileimageNew Project. Choose Android Project from the list and then click the Next button.
  2. Fill out the project settings. For the appropriate values, refer to Table 6-1.

    Table 6-1 Project Settings for Screen Brightness Toggle

    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

    image 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.

  3. Click the Finish button.

    Your new Screen Brightness Toggle application appears in your Package Explorer, as shown in Figure 6-1.

    image 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 ToolsimageFix Project Properties. Doing this realigns your project with the IDE workspace.

    Figure 6-1: The Screen Brightness Toggle application in Eclipse.

    image

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

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