Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 9th, 2011, 03:18 PM
Registered User
 
Join Date: Aug 2011
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 7 Provider pg239 crashes in android-10

This example runs in an android-9 emulator (2.3.1) but not in android-10 (2.3.3). All previous examples in the book run fine in 2.3.3.

Just a caution to others learning from the book. The book specifies that is was written and tested with version 2.3 (pg. xv), and based on the above example I would advise sticking with 2.3.1.

What I can't tell anyone is how to track down such errors. If you have more useful and specific information about how to track down the cause of such exceptions please feel free to comment. I didn't see anything useful in the stack trace. It was a runtime exception thrown on the managedQuery line:

Code:
Cursor c = managedQuery(allContacts, null, null, null, null);
Modifying the previous line allows the example to run in 2.3.3:

Code:
From:
Uri allContacts = Uri.parse("content://contacts/people");

To:
Uri allContacts = ContactsContract.Contacts.CONTENT_URI;
Sometimes when the documentation says something is deprecated you really must take note.

HTML Code:
http://developer.android.com/reference/android/app/Activity.html#managedQuery%28android.net.Uri,%20java.lang.String[],%20java.lang.String,%20java.lang.String[],%20java.lang.String%29
Code:
public final Cursor managedQuery (Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
Since: API Level 1

This method is deprecated.
Use CursorLoader instead.

Wrapper around query(android.net.Uri, String[], String, String[], String) that gives the resulting Cursor to call startManagingCursor(Cursor) so that the activity will manage its lifecycle for you. If you are targeting HONEYCOMB or later, consider instead using LoaderManager instead, available via getLoaderManager().

Last edited by mtvoyd; September 9th, 2011 at 04:07 PM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Android SDK/Android.bat does not find SWT.jar file chaoticandroid BOOK: Professional Android 2 Application Development 1 March 23rd, 2011 06:39 PM
Ch 10 tixrus BOOK: Beginning JavaScript and CSS Development with jQuery 0 April 10th, 2010 01:27 PM
C# Ch 10 Page 362 surefire BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 February 25th, 2008 01:55 PM
Problems with the editor example in ch 10 arne Beginning PHP 4 August 21st, 2004 02:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.