Reviews

Appportunity App Solutions Review

Appportunity App Solutions Review

Articles

Creating a Compass View Example

Android Drawcircle Drawline Example

In the following example you'll create a new Compass View by extending the View class. This View will display a traditional compass rose to indicate a heading orientation. When complete, it should appear as in Figure 4-2. A compass is an example of a UI control that requires a radically different visual display from the Text Views and Buttons available in the SDK toolbox, making it an excellent candidate for building from scratch. In Chapter 14 you'll use this Compass View and the device's...

Opening a Bluetooth Server Socket Listener

A Bluetooth Server Socket is used to listen for incoming Bluetooth Socket connection requests from remote Bluetooth Devices. In order for two Bluetooth devices to be connected, one must act as a server listening for and accepting incoming requests and the other as a client initiating the request to connect to the server . Once the two are connected, the communications between the server and host device are handled through a Bluetooth Socket at both ends. To listen for incoming connection...

Adding Video Metadata

As we discussed in Chapter 9, Android's MediaStore content provider has a portion, MediaStore.Video, dedicated to video in addition to the portions for image and audio files and metadata that we have previously looked at. When triggering the Camera application via an intent, the Uri to the newly recorded video file that is returned is a content style Uri, which is used in combination with a content provider in this case, the MediaStore. In order to add additional metadata, we can use the Uri...

Raw Audio Recording with Audio Record

Aside from using an intent to launch the sound recorder and using the MediaRecorder, Android offers a third method to capture audio, using a class called AudioRecord. AudioRecord is the most flexible of the three methods in that it allows us access to the raw audio stream but has the least number of built-in capabilities, such as not automatically compressing the audio. The basics for using AudioRecord are straightforward. We simply need to construct an object of type AudioRecord, passing in...

Documents To Go Desktop with Documents To Go Full version

The Documents To Go Desktop application must be installed in order to facilitate synchronization. When installed, Windows users can easily sync files between their computer and device via USB cable. Once the files are set to sync, any edits made will automatically be transferred upon synchronization. Note Desktop synchronization is a separate add-on for Documents To Go that is part of Documents To Go Full version 3. If you are using version 2 of Documents To Go Full or are using the Viewer...

Installing the Win Usb Driver

A WinUsb-based driver is needed in order to use your Android-powered device for development on a Windows machine. The USB installation package can be found in the lt sdk gt usb driver folder of your SDK package. Note If you are connecting an Android-powered device to your computer for the first time, folllow the procedure to Perform a fresh installation. Android SDKs older than version 1.6 included a non-WinUsb-based driver for connecting your device. If you installed the older USB driver and...

Externalizing Resources

No matter what your development environment, it's always good practice to keep non-code resources like images and string constants external to your code. Android supports the externalization of resources ranging from simple values such as strings and colors to more complex resources like images Drawables , animations, and themes. Perhaps the most powerful externalizable resources are layouts. Prepared for ASHLEE KABAT, email akabat spam.la Order number 56760408 This PDF is for the purchaser's...

Types of Android Applications

Most of the applications you create in Android will fall into one of the following categories > Foreground An application that's useful only when it's in the foreground and is effectively suspended when it's not visible. Games and map mashups are common examples. > Background An application with limited interaction that, apart from when being configured, spends most of its lifetime hidden. Examples include call screening applications and SMS auto-responders. > Intermittent Expects some...

Recipe Manipulating Raw Audio

The MediaRecorder MediaPlayer framework is useful for most audio uses, but to manipulate raw audio straight from the microphone, process it without saving to a file, and or play back raw audio, use AudioRecord AudioTrack instead. First, set the permission in the AndroidManifest XML file lt uses-permission gt Then, the steps to record are 1. Create an AudioRecord instance, specifying the following to the constructor Audio source Use one of the MediaRecorder.AudioSource choices described in the...

Raw Audio Capture and Playback Example

Here is a full example that records using AudioRecord and plays back using AudioTrack. Each of these operations lives in their own thread through the use of AsyncTask, so that they don't make the application become unresponsive by running in the main thread. package import java. import java. import java. import java. import java. import java. import java. import java. import android.view.View.OnClickListener public class AltAudioRecorder extends Activity implements OnClickListener We have two...

Monitoring Changes in Phone State Phone Activity and Data Connections

The Android telephony API lets you monitor phone state, retrieve incoming phone numbers, and observe changes to data connections, signal strength, and network connectivity. In order to monitor and manage phone state, your application must specify the READ_PHONE_STATE uses-permission in its manifest using the following XML code snippet lt uses-permission Changes to the phone state are monitored using the PhoneStateListener class. Extend the Phone State Listener to listen for, and respond to,...

Replacing the Native Dialer

Replacing the native dialer application involves two steps 1. Intercepting Intents that are currently serviced by the native dialer. 2. Initiating, and optionally managing, outgoing calls. The native dialer application currently responds to Intent actions corresponding to a user's pressing the hardware call button, asking to view data using the tel schema, or making a request to dial a number using the tel schema. To intercept these requests include lt intent-filter gt tags on your new Activity...

Managing files and documents

Android doesn't come with a file browser or editor but help is at hand 11 play and no work makes your smartphone an expensive toy. But with the help of a wide selection of professional-grade mobile apps from the Android Market, your Android device can get down to business. Here's an overview of some of the best apps for viewing, creating and editing business documents on the go. You have several ways to move files onto, off and around your Android phone. The easiest method is to connect your...

Network Video Playback

Mediaplayer Onerrorlistener

Android supports HTTP and RTSP video playback in all three video playback methods discussed in Chapter 9. Using either the built-in Media Player activity via an intent or the VideoView class to play either form of network video requires no source code changes. Simply use the HTTP or RTSP URL as the video Uri, and it will work as long as the format is supported. Here is the ViewTheVideo activity example from Chapter 9 that uses a VideoView with an RTSP URL to a video from YouTube's mobile site....

Emergency Responder SMS Example

In this example, you'll create an SMS application that turns an Android phone into an emergency response beacon. Once finished, the next time you're in unfortunate proximity to an alien invasion or find yourself in a robot-uprising scenario, you can set your phone to automatically respond to your friends' and family members' pleas for a status update with a friendly message or a desperate cry for help . To make things easier for your would-be saviors, you'll use location-based services to tell...

Media Recorder Example

Here is the code for a full custom audio capture and playback example using the MediaRecorder class. package import java.io.File import java.io.IOException import import android.view.View.OnClickListener Our CustomRecorder activity implements OnClickListener so that it may be notified when Buttons are pressed, and OnCompletionListener so that it can respond when MediaPlayer has completed playing audio. public class CustomRecorder extends Activity implements OnClickListener, OnCompletionListener...

Broadcast receiver lifecycle

A broadcast receiver has single callback method void onReceive(Context curContext, Intent broadcastMsg) When a broadcast message arrives for the receiver, Android calls its onReceive() method and passes it the Intent object containing the message. The broadcast receiver is considered to be active only while it is executing this method. When onReceive() returns, it is inactive. A process with an active broadcast receiver is protected from being killed. But a process with only inactive components...

Welcome to the Warescription

We hope you enjoy this ebook and its updates - keep tabs on the Warescription feed off the CommonsWare site to learn when new editions of this book, or other books in your Warescription, are available. All editions of CommonsWare titles, print and ebook, follow a softwarestyle numbering system. Major releases 1.0, 2.0, etc. are available in both print and ebook minor releases 0.1, 0.9, etc. are available in ebook form for Warescription subscribers only. Releases ending in .9 are release...

Recipe Using Image Buttons in a Table Layout

Android Scaletype

Buttons were introduced in Chapter 2. Like any view, a background image can be added to a button using the android background attribute. However, using the special ImageButton widget provides some additional layout flexibility. It specifies an image using the android src attribute as follows When used in this way, the image shows on top of a button widget.The ImageButton inherits image placement from the ImageView widget using android scaleType. Possible values and how they modify a given image...

Playing Sound with Audio Track

Use the AudioTrack class to play raw audio directly into the hardware buffers. Create a new Audio Track object, specifying the streaming mode, frequency, channel configuration, and the audio encoding type and length of the audio to play back. AudioTrack audioTrack new Because this is raw audio, there is no meta-data associated with the recorded files, so it's important to correctly set the audio data properties to the same values as those used when recording the file. When your Audio Track is...

Recipe Translating a Location to Address Reverse Geocoding

The Geocoder class provides a method to translate from an address into a latitude-longitude coordinate geocoding and from a latitude-longitude coordinate into an address reverse geocoding . Reverse geocoding might produce only a partial address, such as city and postal code, depending on the level of detail available to the location provider. This recipe uses reverse geocoding to get an address from the device's location and display to the screen, as shown in Figure 10.2.The Geocoder instance...

Remote procedure calls

Heirship Chart Texas

Android has a lightweight mechanism for remote procedure calls RPCs where a method is called locally, but executed remotely in another process , with any result returned back to the caller. This entails decomposing the method call and all its attendant data to a level the operating system can understand, transmitting it from the local process and address space to the remote process and address space, and reassembling and reenacting the call there. Return values have to be transmitted in the...

Google Maps External Library

To make it easier for you to add powerful mapping capabilities to your application, Google provides a Maps external library that includes the com.google.android.maps package. The classes of the com.google.android.maps package offer built-in downloading, rendering, and caching of Maps tiles, as well as a variety of display options and controls. The key class in the Maps package is com.google.android.maps.MapView, a subclass of ViewGroup. A MapView displays a map with data obtained from the...

Audio Capture with an Intent

Record Sound Action

The easiest way to simply allow audio recording capabilities in an application is to leverage an existing application through an intent that provides recording capabilities. In the case of audio, Android ships with a sound recorder application that can be triggered in this manner. The action used to create the intent is available as a constant called RECORD_SOUND_ACTION within the MediaStore.Audio.Media class. Here is the basic code to trigger the built-in sound recorder. Intent intent new...

Introducing Itemized Overlays and Overlay Items

Overlayitems are used to supply simple maker functionality to your Map Views via the ItemizedOverlay class. itemizedOverlays provide a convenient shortcut for adding markers to a map, letting you assign a marker image and associated text to a particular geographical position. The ItemizedOverlay instance handles the drawing, placement, click handling, focus control, and layout optimization of each Overlayitem marker for you. To add an itemizedOverlay marker layer to your map, start by creating...

Supported Audio Formats

Android supports a variety of audio file formats and codecs for playback it supports fewer for recording, which we'll discuss when we go over recording . AAC Advanced Audio Coding codec as well as both profiles of HE-AAC, High Efficiency AAC , .m4a audio m4a or.3gp audio 3gpp files. AAC is a popular standard that is used by the iPod and other portable media players. Android supports this audio format inside of MPEG-4 audio files and inside of 3GP files which are based on the MPEG-4 format ....

Dalvik Debug Monitor Service ddms

Dalvik Debug Monitor Service is a tool that assists you in debugging your application. It uses Android Debug Bridge to connect to a device and help you debug applications running inside a Dalvik virtual machine. Using the Dalvik Debug Monitor Service, you can monitor thread and heap information, move files to and from the device or emulator, simulate incoming calls and SMS, send location information to simulate GPS information, and more. You can access some of these functionalities using the...

Native Android Actions

Native Android applications also use Intents to launch Activities and sub-Activities. The following non-comprehensive list shows some of the native actions available as static string constants in the Intent class. When creating implicit Intents you can use these actions, called Activity Intents, to start Activities and sub-Activities within your own applications. Later you will be introduced to Intent Filters and you'll learn how to register your own Activities as handlers for these actions....

Understanding the Android SDK License Agreement

Before you can download the Android SDK, you must review and agree to the Android SDK License Agreement. This agreement is a contract between you (the developer) and Google (copyright holder of the Android SDK). Even if someone at your company has agreed to the Licensing Agreement on your behalf, it is important for you, the developer, to be aware of a few important points 1. Rights granted Google (as the copyright holder of Android) grants you a limited, worldwide, royalty-free,...

Using The Manifest Editor

The ADT plug-in includes a visual Manifest Editor so you don't have to manipulate the underlying XML directly. To use the Manifest Editor in Eclipse, right-click the AndroidManifest.xml file in your project folder and select Open With O Android Manifest Editor. This presents the Android Manifest Overview screen, as shown in Figure 3-1. This screen gives you a high-level view of your application structure, enabling you to set your application version information and root level manifest nodes,...

Download the Android SDK

Android Versions Usage

PhoneGap works in conjunction with the Android SDK, so before we can get started with PhoneGap, we need to download and install the Android SDK itself. Follow the steps here to do so 1. Navigate to the Android SDK download page and download the package appropriate for your platform. If you are on Windows or Linux, you will need to install Java see http java.sun.com javase downloads first. My development machine is a MacBook Pro running Mac OS X 10.6, so in my case, the appropriate package is...

Loading and Examining Bitmaps

The Bitmap class will become our best friend. We load a bitmap from a file by using the BitmapFactory singleton. As we store our images in the form of assets, let's see how we can load an image from the assets directory InputStream inputStream assetManager.open(bob.png) Bitmap bitmap The Bitmap class itself has a couple of methods that are of interest to us. First we want to get to know its width and height in pixels int width bitmap.getWidth() int height bitmap.getHeight() The next thing we...

Identifying Your Target Audience

As you learned in the previous chapter, identifying your app's unique message is one of the keys to successful marketing. Now it's time to take a look at your target market so you can carefully focus your message to the right audience. Some app developers think it doesn't really matter if they identify their target market. As long as their app is on the Android Market, it will take care of itself. They think the right people will find their app regardless of what they do, especially if they get...

Creating a Dynamic Manifest File

Now that you're comfortable with how the offline app cache works, let's apply it to the Kilo example we've been working on. Kilo consists of quite a few files and manually listing them all in a manifest file would be a pain. Plus, a single typo would invalidate the entire manifest file and prevent the application from working offline. Running PHP Scripts on Your Web Server PHP is a versatile web-scripting language, and is supported by most web hosting providers. This means that on most web...

Understanding Ringtone Preference

RingtonePreference deals specifically with ringtones. You'd use it in an application that gives the user an option to select a ringtone as a preference. Figure 11-5 shows the UI of the RingtonePreference example and Listing 11-6 shows the XML. Figure 11-5. The RingtonePreference example UI Figure 11-5. The RingtonePreference example UI Listing 11-6. Defining a RingtonePreference Preference ringtone.xml (store at res xml ringtone.xml) < xml version 1.0 encoding utf-8 > < PreferenceScreen...

Native Preference Controls

Android includes several preference controls to build your Preference Screens > CheckBoxPreference A standard preference checkbox control. Used to set preferences to true or false. > EditTextPreference Allows users to enter a string value as a preference. Selecting the preference text will display a text entry dialog. > ListPreference The preference equivalent of a spinner. Selecting this preference will display a dialog box containing a list of values from which to select. You can...

OnStart Command vs onStart

The onStartCommand method was introduced with Android 2.0 API level 5 . Previous to that, the method used was onStart. onStart's parameters are an intent and an int for startId. It does not include the int flags parameter and doesn't have a return. If you are targeting a phone that is running something earlier than 2.0, you can use the onStart method. public void onStart Intent intent, int startid The onDestroy method is called when the OS is destroying a Service. In this example, it is...

Interacting with the phone

In your day-to-day development you will often want to interact with the phone. This interaction may be as simple as dialing outbound calls through built-in intents, or it may involve intercepting calls to modify them in some way. In this section we are going to cover these basic tasks, and we will examine some of the phone number utilities Android provides for you out of the box. One of the more common things you will do with the Android telephony support doesn't involve the telephony APIs...

Creating a Map Based Activity

To use maps in your applications you need to extend MapActivity. The layout for the new class must then include a MapView to display a Google Maps interface element. The Android maps library is not a standard Android package as an optional API, it must be explicitly included in the application manifest before it can be used. Add the library to your manifest using a uses-library tag within the application node, as shown in the following XML snippet lt uses-library The maps package as described...

Designating a Primary Entry Point Activity for Your Application Using an Intent Filter

An Activity class can be designated as the primary entry point by configuring an intent filter using the Android manifest tag < intent-filter> in the application's AndroidManifest.xml file with the MAIN action type and the LAUNCHER category. Registering Activities and Other Application Components 93 The following tag of XML configures the Activity class called MultimediaMenuActivity as the primary launching point of the application < activity < intent-filter> < action MAIN > <...

Handling Long Clicks with setOnLong ClickListener

A long-click is a special type of click available on the Android platform. Basically, a long-click event is when a user clicks on a control for about one second. This type of click is handled separately from a regular, short click. To handle long-clicks, you need to implement the View.OnLongClickListener class and pass it into the ImageButton control's setOnLongClickListener method. OnLongClickListener has one required method you must implement onLongClick . Here is a sample implementation of...

Providing Mock Location Data

When testing your application on the Android emulator, there are a couple different ways to send it some mock location data you can use the DDMS tool or the geo command option in the emulator console. With the DDMS tool, you can simulate location data a few different ways Manually send individual longitude latitude coordinates to the device. Use a GPX file describing a route for playback to the device. Use a KML file describing individual placemarks for sequenced playback to the device. For...

Using the Contacts Provider

Access to the contact manager is particularly useful on a communications device. Android does the right thing by exposing all the information available from the contacts database to any application granted the READ_CONTACTS permission. Android 2.0 API level 5 introduced the ContactsContract class, which superceded the Contacts class that had previously been used to store and manage the contacts stored on the device. The new contact Content Provider extends the scope of contacts management in...

Performing Inter Process Communication

Android Aidl Diagram

Communication between application components in different processes is made possible in Android by a specific IPC approach. This, again, is necessary because each application on the platform runs in its own process, and processes are intentionally separated from one another. In order to pass messages and objects between processes, you have to use the Android IPC path. To begin exploring this path we are first going to build a small, focused sample application to examine the means to generate a...

Working with messaging SMS

SMS is a hugely popular and important means of communication for mobile devices. SMS is used to send simple text messages and small amounts of data. Android includes a built-in SMS application that allows users to view received SMS messages and send messages including replying to received messages . Along with the built-in user-facing support and the related ContentProvider for interacting with the built-in system, the SDK provides APIs for developers to be able to send and receive messages...

Creating a Simple jQTouch Application

The user will go to a page that is the jQTouch application. This page includes jQuery, jQTouch JavaScript, jQtouch CSS, and a theme to skin the application with. While you don't need to (and shouldn't) modify the jQTouch CSS file, it is helpful to understand that the jQTouch CSS file contains the transition classes (such as slide, pop, and so forth) and defines the WebKit animations for each transition. Typically, you will use the jQTouch styles by annotating your HTML with the jQTouch classes....

Whats Making My OpenGL ES Rendering So Slow

That the Hero is slower than the second-generation devices is no big surprise. However, the PowerVR chip in the Droid is slightly faster than the Adreno chip in the Nexus One, so the preceding results are a little bit strange at first sight. On further inspection we can probably attribute the difference not to the GPU power but to the fact that we call many OpenGL ES methods each frame, which are costly Java Native Interface methods. This means that they actually call into C code, which costs...

Recipe Starting a Service When the Camera Button Is Pressed

This recipe shows how to start a service based on a broadcasted event, such as when the camera button is pressed. The broadcast receiver is needed to listen for the specified event s and subsequently launch the service.The broadcast receiver itself is started in another component. Here, it is implemented as a standalone activity, SimpleActivity. The activity shown in Listing 3.14 sets up a broadcast receiver and sets up an intent with the filter for the camera button. The filter for...

Mapping applications to processes

Android applications each run in a single Linux process. Android relies on Linux for process management, and the application itself runs in an instance of the Dalvik virtual machine. The OS may need to unload, or even kill, an application from time to time to accommodate resource allocation demands. There is a hierarchy or sequence the system uses to select the victim of a resource shortage. In general, the rules are as follows Visible, running activities have top priority. Visible, nonrunning...

Listening for Incoming SMS Messages

When a new SMS message is received by the device, a new broadcast Intent is fired with the android.provider.Telephony.SMS_RECEIVED action. Note that this is a string literal, the SDK currently doesn't include a reference to this string, so you must specify it explicitly when using it in your applications. The SMS received action string is hidden therefore unsupported . As such it is subject to change at any future platform release. As always, be very cautious when using unsupported platform...

Bluetooth Data Transfer Example

The following example uses the Android Bluetooth APIs to construct a simple peer-to-peer messaging system that works between two paired Bluetooth devices. Unfortunately the Android emulator can't currently be used to test Bluetooth functionality. In order to test this application you will need to have two physical devices. 1. Start by creating a new BluetoothTexting project featuring a BluetoothTexting Activity. Modify the manifest to include Bluetooth and bluetooth_admin permissions. lt xml...

Compiling Doom with NDK

If you read this book carefully, you'll get the sense that that I don't like the NDK 1.5 when I started in this project the NDK didn't even exist . I think the NDK 1.5 is cumbersome to use, because of the lack of integration with the Eclipse workbench. Plus, version 1.5 has only the bare bones to compile a native library that is, the C runtime, Compression library, and basic C support . Just when this book was being finished up, Google released the NDK 1.6, a nice improvement over 1.5. Here are...

Exploring Android Telephony Internals

A lot of code lies between creating an ACTION_CALL Intent object and dialing a call. Here we will go even deeper into Android's telephony system to see what Android is telling the mobile radio, and match that up with what we have done in the example application earlier in this chapter. To see how, and when, Android actually commands the hardware to dial a number, we can use Android's logging system. To access the log buffer for information about the traffic between Android software and the...

DDMS Dalvik Debug Monitor Service

Installing the Android Software Development Kit adds DDMS to the Eclipse integrated development environment, providing a window-oriented interface to Android-specific debug information on the target. The most frequently used perspectives are displayed in the upper-right corner of the Eclipse window. If there's a DDMS button there, you can just click on it to switch to DDMS. If not, in that same area there is a little window symbol with a sign in its upper-right corner. Clicking on this window...

Developing an End User Application with the Android SDK

In this section, we'll introduce you to the high-level Android Java APIs that you'll use to develop end-user applications for an Android handheld. We will briefly talk about the Android phone emulator and foundational components, UI programming, services, media, telephony, animation, and OpenGL. We will also show you some code snippets when they are helpful. The Android SDK ships with an Eclipse plug-in called Android Development Tools (ADT). You will use this Integrated Development Environment...

Maps Geocoding and Location Based Services

gt Forward and reverse geocoding gt Creating interactive maps with Map Views and Map Activities gt Creating and adding Overlays to maps gt Finding your location with location-based services One of the defining features of mobile phones is their portability, so it's not surprising that some of the most enticing Android features are the services that let you find, contextualize, and map physical locations. You can create map-based Activities using Google Maps as a user interface element. You...

Setting hardware emulation options

When are creating a new AVD that uses a standard Android system image (Type platform), the android tool lets you set hardware emulation options for virtual device. The table below lists the options available and the default values, as well as the names of properties that store the emulated hardware options in the AVD's configuration file (the config.ini file in the AVD's local directory). The amount of physical RAM on the device, in megabytes. Default value is 96. Whether there is a touch...

Editing Project Resources

By default, the Android manifest file resource editor is opened when you create a new Android project. If you have clicked away from this screen to check out the various project files, simply double-click the AndroidManifest.xml file within your new project to return to the Android manifest file resource editor (see Figure 1.3). Editing an Android resource file in Eclipse. The Android manifest file is the central configuration file for an Android application. The editor organizes the manifest...

Configuring the Android Manifest File

The Android application manifest file is a specially formatted XML file that must accompany each Android application. This file contains important information about the application's identity. Here you define the application's name and version information and what application components the application relies upon, what permissions the application requires to run, and other application configuration information. The Android manifest file is named AndroidManifest.xml and must be included at the...

Returning Data from the Camera

Of course, simply capturing an image using the built-in camera application won't actually be useful without having the Camera application return the picture to the calling activity when one is captured. This can be accomplished by substituting the startActivity method in our activity with the startActivityForResult method. Using this method allows us the ability to access the data returned from the Camera application, which happens to be the image that was captured by the user as a Bitmap....

Fundamental Android Ui Design

User interface UI design, user experience UX , human computer interaction HCI , and usability are huge topics that aren't covered in great depth in this book. Nonetheless, it's important that you get them right when creating your user interfaces. Android introduces some new terminology for familiar programming metaphors that will be explored in detail in the following sections gt Views Views are the base class for all visual interface elements commonly known as controls or widgets . All UI...

Listening in with broadcast receivers

Another way to use an Intent involves sending a broadcast to any interested receiver. There are many reasons an application may want to broadcast an event for example, when an incoming phone call or text message is received. In this section we will take a look at how events are broadcast and how they are captured using a BroadcastReceiver. Here we will continue working through the WeatherReporter sample application we began in the previous section. One of the most important parts of the...

Android Project Wizard

The most straightforward manner to create an Android application is to utilize the services of the Android Project Wizard, which is part of the ADT plug-in. The wizard provides a simple means to define the Eclipse project name and location, the Activity name corresponding to the main UI class, as well as a name for the application. Of importance also is the Java package name under which the application is created. Once this application is created, it is easy to add new classes to the project....

Signing in Debug Mode

The Android build tools provide a debug signing mode that makes it easier for you to develop and debug your application, while still meeting the Android system requirement for signing your .apk when it is installed in the emulator or a device. When you use debug mode, the SDK tools invoke Keytool to create a debug keystore and key. The SDK tools create the debug keystore key with predetermined names passwords Keystore name - debug.keystore Keystore password - android Key alias - androiddebugkey...

Drawing on Existing Images

Since we are drawing on a Canvas, we can use techniques described in the previous chapter to draw an image to the Canvas and then draw on top of that image. package import java.io.FileNotFoundException import android.app.Activity import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Canvas import android.graphics.Color import android.graphics.Matrix import android.graphics.Paint import android.net.Uri import android.os.Bundle...

Debugging with strace

For some reason, the native test program for the library runs in version 1.0 R2 of the SDK, but fails to load in 1.5 R2. The output gives a clue the file bionic linker linker.c 1581 fails to load the library. There is a simple Linux tool called strace that can help in this situation. The strace tool runs the specified command until it exits. It intercepts and records the system calls that are called by a process and the signals that are received by a process. The name of each system call, its...

Hardware Imposed Design Considerations

Small and portable, mobile devices offer exciting opportunities for software development. Their limited screen size and reduced memory, storage, and processor power are far less exciting, and instead present some unique challenges. Compared to desktop or notebook computers, mobile devices have relatively High costs associated with data transfer Slow data transfer rates with high latency Each new generation of phones improves many of these restrictions. In particular, newer phones have...

Designing and Developing Bulletproof Android Applications 571

Best Practices in Designing Bulletproof Mobile Applications 571 Meeting Mobile Users' Demands 572 Designing User Interfaces for Mobile Devices 572 Designing Stable and Responsive Mobile Applications 573 Designing Secure Mobile Applications 574 Designing Mobile Applications for Maximum Profit 575 Leveraging Third-Party Standards for Android Application Design 576 Designing Mobile Applications for Ease of Maintenance and Upgrades 576 Leveraging Android Tools for Application Design 578 Avoiding...

Understanding Application Priority And Process States

The order in which processes are killed to reclaim resources is determined by the priority of the hosted applications. An application's priority is equal to its highest-priority component. If two applications have the same priority, the process that has been at a lower priority longest will be killed first. Process priority is also affected by interprocess dependencies if an application has a dependency on a Service or Content Provider supplied by a second application, the secondary application...

Using Internet Resources

Android offers several ways to leverage Internet resources. At one extreme you can use a WebView to include a WebKit-based browser View within an Activity. At the other extreme you can use client-side APIs such as Google's GData APIs to interact directly with server processes. Somewhere in between, you can process remote XML feeds to extract and process data using a Java-based XML parser such as sax or the more efficient XmlPullParser. Detailed instructions for parsing XML and interacting with...