About me
Contact
logo

Creating Your First Android Activity

10:58 PM // 0 comments // Sajib Barua // Category: Android Applications //

previous Getting Started with Android
You’ve downloaded the SDK, installed Eclipse, and plugged in the plug-in. You’re now ready to start programming for Android. Start by creating a new project and setting up your Eclipse run and debug configurations.
Starting a New Android Project
To create a new Android project using the Android New Project Wizard:
  1. Select File ➪ New ➪ Project.
  2. Select the Android Project application type from the Android folder, and click Finish.
  3. In the dialog that appears (shown in Figure 2-4), enter the details for your new project. The “Project name” is the name of your project fi le; the “Package name” specifies its package; the “Activity name” is the name of the class that is your initial Activity; and the “Application name” is the friendly name for your application.image
  4. When you’ve entered the details, click Finish.
The ADT plug-in then creates a new project that includes a new class that extends Activity. Rather than being completely empty, the default template implements “Hello World.” Before modifying the project, take this opportunity to configure run and debug launch configurations.
Creating a Launch Configuration
Launch configurations let you specify runtime options for running and debugging applications. Using a launch configuration you can specify the following:
  • The Project and Activity to launch
  • The emulator options to use
  • Input/output settings (including console defaults)
You can specify different launch configurations for Run and Debug modes. The following steps show how to create a launch configuration for an Android application:
  1. Select Run ➪ Open Run Dialog … (or Run ➪ Open Debug Dialog …).
  2. Right-click Android Application on the project type list, and select New.
  3. Enter a name for the configuration. You can create multiple configurations for each project, so create a descriptive title that will help you identify this particular setup.
  4. Now choose your start-up options. The first (Android) tab lets you select the project and Activity that you want to start when you run (or debug) the application. Figure 2-5 shows the settings for the project you created earlier.image
  5. Use the Target tab to configure the emulator. There are options to choose the screen size, device skin, and network connection settings. You can also optionally wipe the user data on the emulator and enable or disable the start-up animation. Using the command-line textbox, you can specify additional emulator start-up options if needed.
  6. Finally, set any additional properties in the Common tab.
  7. Click Apply, and your launch configuration will be saved.
Running and Debugging Your Android Applications
You’ve created your first project and created the run and debug configurations for it. Before making any changes, test your installation and configurations by running and debugging the Hello World project.
From the Run menu, select Run or Debug to launch the most recently selected configuration, or select Open Run Dialog … or Open Debug Dialog … to select a configuration to use.
If you’re using the ADT plug-in, running or debugging your application:
  • Compiles the current project and converts it to an Android executable (.dex).
  • Packages the executable and external resources into an Android package (.apk).
  • Starts the emulator (if it’s not already running).
  • Installs your application onto the emulator.
  • Starts your application.
If you’re debugging, the Eclipse debugger will then be attached, allowing you to set breakpoints and debug your code.
If everything is working correctly, you’ll see a new Activity running in the emulator, as shown in Figure 2-6.
image
next Understanding Hello World



Bookmark and Share

Related posts :

0 comments for this post

Leave a reply

Older Post
Newer Post
  • IT
  • ft
  • Virtual Assistant
  • Online TV
  • SEO
  • Optimization
  • Satellite TV

Subscribe to Engineering Resources

Receive New Articles As They are Posted

  • Recent posts
  • Recent comments

About Me

Sajib Barua
View my complete profile
  • Home
  • About me
  • Contact
  • RSS