Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2011, 03:18 PM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.