Skip to main content

Professional Android 4 Application Development

Professional Android 4 Application Development

Reto Meier

ISBN: 978-1-118-23722-9

Apr 2012

864 pages

$29.99

Description

Developers, build mobile Android apps using Android 4

The fast-growing popularity of Android smartphones and tablets creates a huge opportunities for developers. If you're an experienced developer, you can start creating robust mobile Android apps right away with this professional guide to Android 4 application development. Written by one of Google's lead Android developer advocates, this practical book walks you through a series of hands-on projects that illustrate the features of the Android SDK. That includes all the new APIs introduced in Android 3 and 4, including building for tablets, using the Action Bar, Wi-Fi Direct, NFC Beam, and more.

  • Shows experienced developers how to create mobile applications for Android smartphones and tablets
  • Revised and expanded to cover all the Android SDK releases including Android 4.0 (Ice Cream Sandwich), including all updated APIs, and the latest changes to the Android platform.
  • Explains new and enhanced features such as drag and drop, fragments, the action bar, enhanced multitouch support, new environmental sensor support, major improvements to the animation framework, and a range of new communications techniques including NFC and Wi-Fi direct.
  • Provides practical guidance on publishing and marketing your applications, best practices for user experience, and more

This book helps you learn to master the design, lifecycle, and UI of an Android app through practical exercises, which you can then use as a basis for developing your own Android apps.

Related Resources

Instructor

Request an Evaluation Copy for this title

INTRODUCTION xxxvii

CHAPTER 1 Hello, Android 1

CHAPTER 2 Getting Started 19

CHAPTER 3 Creating Applications and Activities 53

CHAPTER 4 Building User Interfaces 95

CHAPTER 5 Intents and Broadcast Receivers 165

CHAPTER 6 Using Internet Resources 201

CHAPTER 7 Files, Saving State, and Preferences 221

CHAPTER 8 Databases and Content Providers 251

CHAPTER 9 Working in the Background 331

CHAPTER 10 Expanding the User Experience 359

CHAPTER 11 Advanced User Experience 425

CHAPTER 12 Hardware Sensors 481

CHAPTER 13 Maps, Geocoding, and Location-Based Services 513

CHAPTER 14 Invading the Home Screen 565

CHAPTER 15 Audio, Video, and Using the Camera 621

CHAPTER 16 Bluetooth, NFC, Networks, and Wi-Fi 665

CHAPTER 17 Telephony and SMS 701

CHAPTER 18 Advanced Android Development 739

CHAPTER 19 Monetizing, Promoting, and Distributing Applications 771

INDEX 787

ReadMe File Download
All Downloadable Code Files Download
256Error in Code,In example code it shows:

db.execSQL( DROP TABLE IF IT EXISTS + DATABASE_TABLE);

Should read:

db.execSQL( DROP TABLE IF EXISTS + DATABASE_TABLE);
08/27/2012
292Error in Code,Listing 8-24:

Currently reads:
<activity android:name=?.DatabaseSkeletonSearchResultsActivity?

Should read:
<activity android:name=?.DatabaseSkeletonSearchActivity?
04/16/2012
292Error in Code,Currently reads:
android:value= .DatabaseSkeletonSearchResultsActivity

Should read:
android:value= .DatabaseSkeletonSearchActivity
04/16/2012
295Error in Code,Listing 8-27:

Currently reads:
String query = args.getString(QUERY_EXTRA_KEY);

Should read:
query = args.getString(QUERY_EXTRA_KEY);
04/16/2012
301Error in Code,Listing 8-34:

Currently reads:
code snippet PA4AD_ Ch08_DatabaseSkeleton/src/MySearchSuggestionsContentProvider.java

Should read:
code snippet PA4AD_ Ch08_DatabaseSkeleton/res/xml/searchablewithsuggestions.xml
04/16/2012
309Error in Code,In the section titled Using the Earthquake Provider, insert a new line as the first line of code for Step 6:
Handler handler = new Handler();
04/16/2012
317Error in Code,Listing 8-35

Currently reads:
String contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;

Should read:
Uri contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
04/16/2012
349Error in Code,Listing 9-14:

Currently reads:
private void listing916() {

Should read:
private void backgroundExecution() {
04/16/2012
350Error in Code,Listing 9-15:

Currently reads:
private void listing916() {

Should read:
private void backgroundExecution() {
04/16/2012
404Error in Code,Listing 10-32:

Currently reads:
Handler hander = new Handler();

Should read:
Handler handler = new Handler();
04/16/2012
510-511Error in Code,In the section titled Creating a Weather Station , Step 7 should be:
 private void updateGUI() {    runOnUiThread(new Runnable() {      public void run() {        if (!Float.isNaN(currentPressure) {          pressureTextView.setText(currentPressure +  hPa );          pressureTextView.invalidate();        }        if (!Float.isNaN(currentLight) {          String lightStr =  Sunny ;          if (currentLight <= SensorManager.LIGHT_CLOUDY)            lightStr =  Night ;          else if (currentLight <= SensorManager.LIGHT_OVERCAST)            lightStr =  Cloudy ;          else if (currentLight <= SensorManager.LIGHT_SUNLIGHT)            lightStr =  Overcast ;          lightTextView.setText(lightStr);          lightTextView.invalidate();        }        if (!Float.isNaN(currentTemperature) {          temperatureTextView.setText(currentTemperature +  C );          temperatureTextView.invalidate();        }      }    });  }; 
04/16/2012
539Error in Code,Listing 13-12:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch13_Mapping/src/MyMapActivity.java
04/16/2012
540Error in Code,Listing 13-13:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch13_Mapping/res/layout/map_layout.xml
04/16/2012
555Error in Code,Listing 13-18:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch13_Mapping/MyItemizedOverlay.java
04/16/2012
577Error in Code,Listing 14-12:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch14_MyWidget/res/xml/widget_provider_info.xml
04/16/2012
577Error in Code,Listing 14-12:

Should be:
 <?xml version= 1.0  encoding= utf-8 ?> <appwidget-provider   xmlns:android= http://schemas.android.com/apk/res/android  android:initialLayout= @layout/my_widget_layout    android:minWidth= 110dp    android:minHeight= 110dp    android:label= @string/widget_label    android:resizeMode= horizontal|vertical    android:previewImage= @drawable/widget_preview    android:updatePeriodMillis= 3600000  /> 
04/16/2012
578Error in Code,Listing 14-13:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch14_MyWidget/AndroidManifest.xml
04/16/2012
586Error in Code,In the section titled Creating an Earthquake Widget , Step 7.1 should be:

 public static String QUAKES_REFRESHED =      com.paad.earthquake.QUAKES_REFRESHED ;    @Override  protected void onHandleIntent(Intent intent) {    refreshEarthquakes();    sendBroadcast(new Intent(QUAKES_REFRESHED));  } 
04/16/2012
601Error in Code,In the section titled Creating an Earthquake Collection View Widget , Step 7 should be:

 private Cursor c;    private Cursor executeQuery() {    String[] projection = new String[] {        EarthquakeProvider.KEY_ID,        EarthquakeProvider.KEY_MAGNITUDE,        EarthquakeProvider.KEY_DETAILS      };     Context appContext = getApplicationContext();    SharedPreferences prefs =       PreferenceManager.getDefaultSharedPreferences(appContext);     int minimumMagnitude =       Integer.parseInt(prefs.getString(PreferencesActivity.PREF_MIN_MAG,  3 ));     String where = EarthquakeProvider.KEY_MAGNITUDE +   >   + minimumMagnitude;     return context.getContentResolver().query(EarthquakeProvider.CONTENT_URI,        projection, where, null, null);   }   public void onCreate() {    c = executeQuery();  }  
04/16/2012
604Error in Code,Also in the section titled Creating an Earthquake Collection View Widget , Step 12 should be:

 @Override protected void onHandleIntent(Intent intent) {   refreshEarthquakes();   sendBroadcast(new Intent(QUAKES_REFRESHED));    Context context = getApplicationContext();   AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);   ComponentName earthquakeWidget =      new ComponentName(context, EarthquakeListWidget.class);   int[] appWidgetIds = appWidgetManager.getAppWidgetIds(earthquakeWidget);    appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds,     R.id.widget_list_view); } 
04/16/2012
607Error in Code,Listing 14-28:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch14_MyLiveFolder/src/MyContentProvider.java
04/16/2012
609Error in Code,Listing 14-30:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch14_MyLiveFolder/src/MyLiveFolder.java
04/16/2012
610Error in Code,Listing 14-31:

The source location for the code snippet is incorrect. It should be:

code snippet PA4AD_Ch14_MyLiveFolder/src/MyLiveFolder.java
04/16/2012
610Error in Code,Listing 14-32:

Currently reads:
<activity android:name= .MyLiveFolder

Should read:
<activity android:name= .MyLiveFolder
04/16/2012
627Error in Code,Listing 15-3:

Currently reads:
 android:id=�@+id/buttonStop�  android:layout_width=�wrap_content�  android:layout_height=�wrap_content�  android:text=�Stop� 

Should read:
 android:id=�@+id/buttonPause�  android:layout_width=�wrap_content�  android:layout_height=�wrap_content�  android:text=�Pause� 
04/16/2012
629Error in Code,Listing 15-4:

Currently reads:
stopButton.setOnClickListener(new OnClickListener() {

Should read:
pauseButton.setOnClickListener(new OnClickListener() {
04/16/2012
671Error in Code,Listing 16-4:

Currently reads:
RESULT_CANCELLED

Should read:
RESULT_CANCELED
04/16/2012
672Error in Code,Listing 16-5:

Currently reads:
blueTooth

Should read:
bluetooth
04/16/2012
678Error in Code,Listing 16-8 should be:

 private void listenForMessages(BluetoothSocket socket,                                     StringBuilder incoming) {       listening = true;         int bufferSize = 1024;       byte[] buffer = new byte[bufferSize];       try {         InputStream instream = socket.getInputStream();         int bytesRead = -1;           while (listening) {           bytesRead = instream.read(buffer);           if (bytesRead != -1) {             String result =   ;             while ((bytesRead == bufferSize) &&                    (buffer[bufferSize-1] != 0)){               result = result + new String(buffer, 0, bytesRead - 1);               bytesRead = instream.read(buffer);             }             result = result + new String(buffer, 0, bytesRead - 1);             incoming.append(result);           }           socket.close();         }       } catch (IOException e) {         Log.e(TAG,  Message received failed. , e);       }       finally {       }     }  
04/16/2012
737Error in Code,In the section titled Automating the Emergency Responder, in Step 12:

Currently reads:
defaultResponseText);

Should read:
AutoResponder.defaultResponseText);
04/16/2012
747Error in Code,Listing 18-5 currently reads:
     } } 
Should read:
     }   } } 
04/16/2012