Hey Eric,

When I was working on a Droid I found that fields were null
unexpectedly when I queried for a specific MIMETYPE.  The display name
for a contact is not null with a GroupMembership MIMETYPE query but
there is no data in the phone number fields.  My guess is that the
Phone.Number MIMETYPE might not have a display name column.  Like me,
you may need two queries.  One with a MIMETYPE that has display name
and another to fetch the numbers where selection is based on the
contact_id or raw_contact id collected in the first query.

Here is a question for you...  How do you put contact data into the
Emulator?  Unfortunately for me, although contacts can be loaded, the
Emulator data cannot be grouped.  This means I am not able to use the
Emulator at all to test my code since I query for the
GroupMembership.CONTENT_ITEM_TYPE.  If you or anyone has a suggestion,
great, my access to the Droid is limited and I really want to put out
a new feature on Alarmoid.

Boas Festas!
Beth


On Dec 23, 9:47 pm, Eric <eric.c.willi...@gmail.com> wrote:
> I'm having problems with my application on Droid phones. I am unable
> to reproduce the problems in the emulator. A co-worker of mine with a
> Droid also has no issues running my app. Any help you can provide
> would be much appreciated.
>
> My application is called Dialify. It's open source; you can find the
> code 
> here:http://code.google.com/p/dialify/source/browse/#svn/trunk/Dialify/src...
>
> My app queries the contacts DB to display a list of contacts. The user
> can select contacts to turn them into notifications that can be dialed/
> texted.
>
> Droid users reported 2 problems:
>
> 1) Contacts not appearing
> 2) App force-closes when they begin to scroll through the contacts
> list
>
> My app creates a cursor over the contacts DB to display contacts. I
> realized problem #1 was due to using the API level 5 method of access
> which only shows contacts for the master account. I fixed this, but
> the force-close issue remains.
>
> Unfortunately, I am unable to replicate a force-close in the emulator.
> I thought maybe it was the number of contacts and created about 200 of
> them, to no avail. It's been happening to users who use Exchange and
> users who do not, so I haven't tried getting Exchange contacts into
> the Emulator.
>
> This is how my deployed app retrieves contacts 
> today:http://code.google.com/p/dialify/source/browse/trunk/Dialify/src/org/...
>
> Here are some of the changes I made for API level 6 compatibility:
>
> //"Phone" is android.provider.ContactsContract.CommonDataKinds.Phone
> private static final String[] PROJECTION = new String[] {
>         ContactsContract.Data._ID,  //0
>         Phone.DISPLAY_NAME,         //1
>         Phone.TYPE,                 //2
>         Phone.LABEL,                //3
>         Phone.NUMBER,               //4
>         Phone.CONTACT_ID            //5
>
> };
>
> private static final String SORT_PHONES_ASC =
>         "upper(" + Phone.DISPLAY_NAME + "),"
>         + Phone.TYPE + ","
>         + "upper(" + Phone.LABEL + ")";
>
> //"Data" is android.provider.ContactsContract.Data
> String selection = Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE +
> "'";
>
> //here's the query itself:
> return _context.getContentResolver().query(
>                 ContactsContract.Data.CONTENT_URI,
>                 PROJECTION,
>                 selection,
>                 selectionArgs, //will be null in this case
>                 sort.getSort() //will be SORT_PHONES_ASC, above
> );
>
> //to display the contact I turn it into an internal type (Contact)
> //_contactTypes comes from resources.getStringArray
> (android.R.array.phoneTypes)
>
> public Contact getContactAtCursor(Cursor cursor) {
>         int typeId = cursor.getInt(2);
>         String type = (typeId == Phone.TYPE_CUSTOM) ? cursor.getString(3) :
> _contactTypes[typeId - 1];
>
>         return new Contact(
>                         cursor.getLong(0),   //id
>                         cursor.getLong(5),   //contact ID
>                         cursor.getString(1), //display name
>                         cursor.getString(4), //number
>                         type
>         );
>
> }
>
> I realize I can bring up a contact selector using an Intent, but I
> don't think that will work for me. My app has a custom view of
> contacts, and it always displays the contacts list.
>
> Any guidance, suggestions, feedback or help would be most welcome. I'm
> not sure how to proceed with this issue.
>
> Regards,
> Eric

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to