Developing Android Applications with Adobe AIR [103]
Figure 17-5. The SavingView and MenuView
Figure 17-6. The PhotoView and the steps to send the picture information using a P2P connection
Permissions
This application needs the following permissions to access the Internet, write to the SD card, and access GPS sensors, the camera, and the microphone:
]]>
Navigation
The ViewManager class discussed here is almost identical to the one discussed in Chapter 16, except that we do not need a back button and breadcrumb navigation. The flow is a step-by-step process whereby the user can choose to skip the steps that are optional.
Images
The CameraView is used to get an image, either by using the media library or by taking one using the camera. The choice is based on a parameter passed from the previous screen. The process of receiving the bytes, scaling, and displaying the image is the same regardless of the image source. It is done by a utility class called BitmapDataSizing and is based on the dimensions of the screen.
To improve this application, check if an image is already saved when the user selects it again to avoid duplicates.
Audio
The audio caption is a novel way to save a comment along with the image. There is no image service that provides the ability to package an audio commentary, but you could build such an application.
As we discussed in Chapter 11, bytes can be saved as WAV files using the Adobe class WAVReader and then extracted using a third-party library. Here, we create an Album directory on the SD card and a mySounds directory inside it to store the WAV files.
Reverse Geolocation
As we covered in Chapter 10, reverse geolocation is the process of using geographical coordinates to get an address location such as a city and a street address.
In this application, we are only interested in the city name and country. Therefore, coarse data is sufficient. We do not need to wait for the GPS data to stabilize. As soon as we get a response for the Yahoo! service, we move on to the next step.
SQLite
SQLManager is a static class, so it can be accessed from anywhere in the application. The Main class holds an object which stores information related to a photo until it is complete and ready to be saved:
var currentPhoto:Object = {photo:"", audio:"", geo:""};
The photo property stores the path to where the image is saved in the Gallery. The audio property stores the path to where the WAV file is located and the geo property stores a string with city and country information.
From the SavingView view, the object is saved in the myAlbum.db file on the SD card.
P2P Connection
The peer-to-peer connection is used to send the image, audio caption, and location over a LAN. This example is to demonstrate the potential of what you can do more than a proper use case because the transfer is slow, unless the information is sent in packets and reassembled. This technology is feasible for fairly small amounts of data and has a lot of potential for gaming and social applications.
Once the user has selected an image, she can transfer it to a companion desktop application from the SavingView view. The PeerService class handles the communication to the LAN and the posting of data.
We cover a lot of this functionality in Chapter 15.
Scrolling Navigation
The MenuView that