Hi,
Did you set the permission to READ_CONTACTS in your AndroidManifest.xml?
On Sun, Jun 15, 2008 at 10:38 AM, Sylvester Steele <
[EMAIL PROTECTED]> wrote:
>
> Hi,
> I've been trying to display contacts in a list. Here's what I did:
>
>
>
>
> activity.setContentView(R.layout.contacts);
> String[] projection = new String[] {
> android.provider.BaseColumns._ID,
> android.provider.Contacts.PeopleColumns.NAME,
>
> //android.provider.Contacts.PhonesColumns.NUMBER,
> //android.provider.Contacts.PeopleColumns.PHOTO
> };
>
> int [] tempInt= new int[]{R.id.contactsList};
>
>
> // Best way to retrieve a query; returns a managed
> query.
> Cursor managedCursor =
> activity.managedQuery(android.provider.Contacts.Phones.CONTENT_URI,
> projection,
> null,
>
> android.provider.Contacts.PeopleColumns.NAME + " ASC"); // Order-by
> clause.
>
>
>
>
> ListView contactsList=
> (ListView)activity.findViewById(R.id.contactsList);
> SimpleCursorAdapter contactsAdapter= new
> SimpleCursorAdapter(activity, android.R.layout.simple_list_item_1,
> managedCursor, projection, tempInt );
> contactsList.setAdapter(contactsAdapter);
>
>
> the above code does not give me and exception etc. but it doesn't
> work. I see a blank list with no data in it. What could be the problem
> and how can it be rectified?
>
> Thanks,
> Sylvester
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---