Online Book Reader

Home Category

Developing Android Applications with Adobe AIR [5]

By Root 2561 0
Flash Player, version 10.1, first became available in Android 2.2 in June 2010. It runs within the device’s native browser. Developing applications for the mobile browser is beyond the scope of this book. However, understanding the similarities and differences between the two environments is important, especially if mobile development is new to you.

Both types of applications are cross-platform rich media applications. They both use the ActionScript language, but AIR for Android only supports ActionScript 3.

Both benefit from recent performance and optimization improvements, such as hardware acceleration for graphics and video, bitmap manipulation, battery and CPU optimization, better memory utilization, and scripting optimization.

Applications running in the Flash Player browser plug-in are typically located on a website and do not require installation. They rely on the Flash plug-in. AIR applications require packaging, certificates, and installation on the device. They rely on the AIR runtime.

Flash Player is subject to the browser sandbox and its restricted environment. The browser security is high because applications may come from many unknown websites. Persistent data is stored in the Flash Local Shared Object, but there is no access to the filesystem. AIR applications function as native applications and have access to local storage and system files. Persistent data may be stored in a local database. The user is informed upon installation of what data the application has access to via a list of permissions.

AIR has additional functionality unique to mobile devices, such as geolocation, accelerometer capability, and access to the camera.

We will build our first application in the next chapter.

Chapter 2. Call Me, Text Me

What we have to learn to do, we learn by doing.

—Aristotle

In this chapter we will build an application to make a phone call, send a text message, and send an email. The first two tasks can only be done from a mobile phone. We will go through the process of creating the AIR application, packaging it as an Android application, and installing it on an Android device. We will then test it and debug it.

If you skipped Chapter 1, go back and follow the instructions to install the AIR runtime on your device from the Android Market.

Development, packaging, and debugging can all be done using Flash Professional CS5.5 or Flash Builder 4.5 (code named Burrito), available in the Adobe labs at the time of this writing. All tools come bundled with the Android Debug Bridge (ADB) used to run and install applications on an Android device.

NOTE

For the rest of the book, we will refer to Flash Professional CS5.5 as just Flash Professional. In addition, we will refer to Flash Builder 4.5 as just Flash Builder.

If you prefer to use other Adobe tools or third-party applications, we will cover some options in the section Other Tools.

Let’s get started.

Setting Up Your Device


To set up your Android device, first select Settings→Applications→Development→USB debugging to initiate development mode on your device. On some devices, such as the Samsung Galaxy Tab, you need to set this first before plugging the device into your development computer; otherwise, the selection is grayed out. When your device is in debug mode, a bug-looking icon appears in the upper-left corner.

Select Settings→Applications→Development→Stay awake to prevent the screen from going to sleep while you are working and testing.

Plug your device into the USB port of your development computer. When your device is connected via USB, a fork-shaped icon appears in the upper-left corner. Figure 2-1 shows the bug and fork icons in the upper-left corner of the screen.

Figure 2-1. Device settings for development

Creating a Project

This section will take you through the process of creating the project step by step.

Using Flash Professional


Launch Flash Professional, create an AIR for Android template, and call it first.fla. The movie has a frame rate of 24 fps and a stage size of 480 by 800 pixels. At first,

Return Main Page Previous Page Next Page

®Online Book Reader