Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Accessing contact's phone numbers
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 30 - Expand all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
agirardello  
View profile  
 More options Oct 30, 11:05 am
From: agirardello <andrea.girarde...@gmail.com>
Date: Fri, 30 Oct 2009 08:05:40 -0700 (PDT)
Local: Fri, Oct 30 2009 11:05 am
Subject: [Android 2.0] Accessing contact's phone numbers
Dear all,

I'm trying to adapt my application (Personalytics) for the brand new
Android 2.0, however I'm facing an issue while accessing contacts'
phone numbers...

What I need to do is to retrieve the name associated to a stored
contact based on his/her phone number. At present I'm doing this in
two steps:
1) from a phone number I get the corresponding ID of the stored
contact (if present)
2) I retrieve the contact's name based on that ID

I managed to use the correct CONTENT_URI for reading contacts by using
reflection to be fully compatible with Android 2.0
(ContactsContract.Contacts.CONTENT_URI) and the previous versions
(People.CONTENT_URI).

Now I'm trying to do the same for Phones.CONTENT_URI (Android <= 1.6)
and ContactsContract.PhoneLookup.CONTENT_FILTER_URI (Android = 2.0)
which is needed by step 2) mentioned above. But as soon as I try to
get a contentResolver by using
ContactsContract.PhoneLookup.CONTENT_FILTER_URI I get the following
exception:

java.lang.IllegalArgumentException: Unknown URL content://com.android.contacts/phone_lookup

This looks really strange to me, since it should be correct (it is
part of the official API)! Moreover, I tried to look at the "API
Demos" project, in particular to the classes:

com.example.android.apis.view.List2
com.example.android.apis.view.List3

which are still using the deprecated People.CONTENT_URI and
Phones.CONTENT_URI and thus no data (i.e. contacts) is loaded (of
course I have sample contacts in the emulator).

- Do you have any suggestion to solve this problem?
- Or is there another approach I can use to get the name of a contact
based on one of his/her numbers? (This must work on all versions of
Android)

Thank you!!!!!!!! ;-)

Andrea


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Jeff Sharkey
Jeff Sharkey  
View profile  
 More options Oct 30, 2:12 pm
From: Jeff Sharkey <jshar...@android.com>
Date: Fri, 30 Oct 2009 11:12:35 -0700
Local: Fri, Oct 30 2009 2:12 pm
Subject: Re: [android-developers] [Android 2.0] Accessing contact's phone numbers
Could you post the exact Uri you're passing to query()?  As the
javadoc describes, you need to append a filter string to the
CONTENT_FILTER_URI so it knows what to filter on.

Uri lookupUri = Uri.withAppendedPath(PhoneLookup.CONTENT_URI, phoneNumber);

Also, you might be able to skip your second step, since you can
directly ask for the PhoneLookup.DISPLAY_NAME column in the
projection.

j

On Fri, Oct 30, 2009 at 8:05 AM, agirardello

--
Jeff Sharkey
jshar...@android.com

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by nEx.Software
nEx.Software  
View profile  
 More options Oct 30, 2:40 pm
From: "nEx.Software" <email.nex.softw...@gmail.com>
Date: Fri, 30 Oct 2009 11:40:15 -0700 (PDT)
Local: Fri, Oct 30 2009 2:40 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Hold up... I'm confused. Are you saying that Contacts portion of the
SDK is deprecated? Whatever happened to "stick to the SDK because
those are stable apis that won't break in future versions"? Very
disappointing...

On Oct 30, 11:12 am, Jeff Sharkey <jshar...@android.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RichardC  
View profile  
 More options Oct 30, 3:57 pm
From: RichardC <richard.crit...@googlemail.com>
Date: Fri, 30 Oct 2009 12:57:34 -0700 (PDT)
Local: Fri, Oct 30 2009 3:57 pm
Subject: Re: Accessing contact's phone numbers
They added support for multiple accounts (woot). However as contacts
are by account something had to give ...

--
RichardC

On Oct 30, 6:40 pm, "nEx.Software" <email.nex.softw...@gmail.com>
wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Jeff Sharkey
Jeff Sharkey  
View profile  
 More options Oct 30, 4:26 pm
From: Jeff Sharkey <jshar...@android.com>
Date: Fri, 30 Oct 2009 13:26:15 -0700
Local: Fri, Oct 30 2009 4:26 pm
Subject: Re: [android-developers] Re: [Android 2.0] Accessing contact's phone numbers
The original, public "android.provider.Contacts" APIs that has shipped
since Android 1.0 are still very much supported, but are now marked as
deprecated.  There are additional features (like multiple accounts)
that will require upgrading to the new
"android.provider.ContactsContract" APIs to access.  For example, only
data from the primary account is exposed through the now-legacy
"android.provider.Contacts" APIs.

j

On Fri, Oct 30, 2009 at 11:40 AM, nEx.Software

--
Jeff Sharkey
jshar...@android.com

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by nEx.Software
nEx.Software  
View profile  
 More options Oct 30, 4:40 pm
From: "nEx.Software" <email.nex.softw...@gmail.com>
Date: Fri, 30 Oct 2009 13:40:45 -0700 (PDT)
Local: Fri, Oct 30 2009 4:40 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Jeff, thanks for clarifying. I'd hate to have seen a bunch of apps
break in the meantime.

On Oct 30, 1:26 pm, Jeff Sharkey <jshar...@android.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Dmitri Plotnikov
Dmitri Plotnikov  
View profile  
 More options Oct 30, 4:05 pm
From: Dmitri Plotnikov <dplotni...@google.com>
Date: Fri, 30 Oct 2009 13:05:26 -0700
Local: Fri, Oct 30 2009 4:05 pm
Subject: Re: [android-developers] Re: [Android 2.0] Accessing contact's phone numbers

It's deprecated, not removed.  The old API is still functional, but with
restrictions:

1. If your app was using something non-public, that part is likely to break.
 We tested a bunch of apps on the market against the legacy API - most
worked, but some did not.  Those were the cases when the app was using some
knowledge of the undocumented underlying database structure.
2. Legacy API will only give you access to the "primary" account, i.e. the
first Google account you add to the phone.

- Dmitri

On Fri, Oct 30, 2009 at 11:40 AM, nEx.Software <email.nex.softw...@gmail.com


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by Ravi
Ravi  
View profile  
 More options Nov 6, 9:31 pm
From: Ravi <textlo...@gmail.com>
Date: Fri, 6 Nov 2009 18:31:21 -0800 (PST)
Local: Fri, Nov 6 2009 9:31 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
That sucks - Is this going to be trend with Android ? I would rather
not put lot of effort every time google comes up with an update, so
far I had to touch/test my apps several times just in few months..
1.0 / 1.1 / 1.5 / 1.6

Now 2.0 Breaks every thing. It's not like any one in the app market
are making money it's for passion and you are making it very difficult
to pursue that.

On Oct 30, 2:05 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ravi  
View profile  
 More options Nov 6, 9:33 pm
From: Ravi <textlo...@gmail.com>
Date: Fri, 6 Nov 2009 18:33:09 -0800 (PST)
Local: Fri, Nov 6 2009 9:33 pm
Subject: Re: Accessing contact's phone numbers
And the worst part is if we use 2.0 API's to have clean code, now i
have to maintain 2 version of the same code base - being from SW
company you should know how difficult it would be. Very disappointing.

On Nov 6, 8:31 pm, Ravi <textlo...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Yao
Yao  
View profile  
 More options Nov 6, 9:37 pm
From: Yao <cicikaka2...@gmail.com>
Date: Sat, 7 Nov 2009 10:37:31 +0800
Local: Fri, Nov 6 2009 9:37 pm
Subject: Re: [android-developers] Re: [Android 2.0] Accessing contact's phone numbers

On Sat, Nov 7, 2009 at 10:31 AM, Ravi <textlo...@gmail.com> wrote:
> That sucks - Is this going to be trend with Android ? I would rather
> not put lot of effort every time google comes up with an update, so
> far I had to touch/test my apps several times just in few months..
> 1.0 / 1.1 / 1.5 / 1.6

> Now 2.0 Breaks every thing. It's not like any one in the app market
> are making money it's for passion and you are making it very difficult
> to pursue that.

Exactly. Especiall account setting doesn't work in emulator, which means
I have to buy a device for 2.0 development. It's difficult for an author of
free software.

--
Best regards,
MTM
Contacts GroupU - Group your Android Contacts
http://contacts-groupu.appspot.com

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by stanlick
stanlick  
View profile  
 More options Nov 17, 3:14 pm
From: stanlick <stanl...@gmail.com>
Date: Tue, 17 Nov 2009 12:14:45 -0800 (PST)
Local: Tues, Nov 17 2009 3:14 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Hey Dmitri --

I have a question regarding the legacy apps only having access to the
"primary" account.  I am writing an application that interfaces with
contacts and started on it before 2.0 was released.  I am developing
with a Motorola CLIQ running 1.5 and my app works fine.  Today, I
purchased a Droid (2.0) and after setting it up I installed this 1.5
application, only to find that I have a much larger list of contacts
and the names in the list are all blank!  The code to read the
contacts is as follows:

                String[] PROJECTION = new String[] { Contacts.People._ID,
                                Contacts.PeopleColumns.NAME };
                Cursor c = managedQuery(Contacts.People.CONTENT_URI, PROJECTION,
null,
                                null, Contacts.People.DEFAULT_SORT_ORDER);

                startManagingCursor(c);
                adapter = new SimpleCursorAdapter(this,
                                android.R.layout.simple_list_item_multiple_choice, c,
                                new String[] { Contacts.PeopleColumns.NAME },
                                new int[] { android.R.id.text1 });
                return adapter;

Can you riddle me this?  Since I selected google mail as an already
existing source of contacts during the activation, was this somehow
designated my "primary" account?  I notice this code is not picking up
contacts I add by hand to the Droid either.  I understand the design
challenges with merging many lists, so I won't scream about this to
you.  However, can you tell me how I would read the contacts under 2.0
and if there is a test I could make in my class to read them the 2.0
way or not?  Also, can you tell me how the contact primary key comes
into play?  I had to create my own SQL database to keep track of my
contact related attributes and I am keying on the _id from the contact
database.

Peace,
Scott

On Oct 30, 2:05 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Dianne Hackborn
Dianne Hackborn  
View profile  
 More options Nov 17, 3:31 pm
From: Dianne Hackborn <hack...@android.com>
Date: Tue, 17 Nov 2009 12:31:19 -0800
Local: Tues, Nov 17 2009 3:31 pm
Subject: Re: [android-developers] Re: [Android 2.0] Accessing contact's phone numbers

On Fri, Nov 6, 2009 at 6:31 PM, Ravi <textlo...@gmail.com> wrote:
> Now 2.0 Breaks every thing.

Wow that's pretty over-the-top.  The original contacts API still works, as
long as you weren't using private parts of it, and only for the primary
Google account.  So it still gives you the same functionality (the new
feature of additional accounts is not accessible from it, but that is why a
new API was required) as before.  And as we've said repeatedly for
everything, if you use private APIs you will break in the future, so that
shouldn't be a surprise.

--
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by nEx.Software
nEx.Software  
View profile  
 More options Nov 17, 3:39 pm
From: "nEx.Software" <email.nex.softw...@gmail.com>
Date: Tue, 17 Nov 2009 12:39:39 -0800 (PST)
Local: Tues, Nov 17 2009 3:39 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
"And as we've said repeatedly for everything, if you use private APIs
you will break in the future, so that shouldn't be a surprise."

You can also get your name on my handy dandy androidhallofshame
website for using private APIs. :)

On Nov 17, 1:31 pm, Dianne Hackborn <hack...@android.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stanlick  
View profile  
 More options Nov 17, 3:47 pm
From: stanlick <stanl...@gmail.com>
Date: Tue, 17 Nov 2009 12:47:35 -0800 (PST)
Local: Tues, Nov 17 2009 3:47 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Both Wow! and over-the-top.  Now I am excited.  This pattern/technique
was lifted from a distinguished Android pro's recent textbook.  So
does the wow imply there is a better way to accomplish the mission?  I
think I considered the contact PICK Intent, but I need to allow the
user to select multiples.  If you can advise a "published" way to pull
this off across the a- versions, I may just buy you a lovely beverage!

Peace,
Scott

On Nov 17, 2:31 pm, Dianne Hackborn <hack...@android.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bonifaz  
View profile  
 More options Nov 18, 1:30 am
From: Bonifaz <bonifaz.kaufm...@gmail.com>
Date: Tue, 17 Nov 2009 22:30:25 -0800 (PST)
Local: Wed, Nov 18 2009 1:30 am
Subject: Re: [Android 2.0] Accessing contact's phone numbers
How do we then get all contacts/phonenumbers from all accounts?
If I use the new Contacts API and send an ACTION.PICK for phone
numbers like

Intent i = new Intent(Intent.ACTION_PICK,
android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_URI);

it doesn't give me for example Facebook account phone numbers.

even

Intent i = new Intent(Intent.ACTION_PICK,
android.provider.ContactsContract.Contacts.CONTENT_URI);

doesn't show a list of all available contacts from all accounts (again
I tried with Facebook contacts and they didn't show up).

Dianne, could you please tell us how we use the PICK intent to get a
list of all available phone numbers from all accounts.

This would be really helpful.

On Nov 17, 3:31 pm, Dianne Hackborn <hack...@android.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukasz Wisniewski  
View profile  
 More options Nov 19, 10:25 am
From: Lukasz Wisniewski <luke.cherr...@gmail.com>
Date: Thu, 19 Nov 2009 07:25:47 -0800 (PST)
Local: Thurs, Nov 19 2009 10:25 am
Subject: Re: Accessing contact's phone numbers
So I am trying to use new contacts API to query for contacts that has
phone number.

resolver.query(
        ContactsContract.Contacts.CONTENT_URI,
        new String[]{ContactsContract.Contacts._ID,
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.Contacts.LOOKUP_KEY},
        ContactsContract.Contacts.HAS_PHONE_NUMBER +" = 1",
        null,
        ContactsContract.Contacts.DISPLAY_NAME+" ASC");

This works fine. However if I query for a phone number based on
phoneLookup key:

resolver.query(
        PhoneLookup.CONTENT_FILTER_URI,
        new String[]{PhoneLookup.NUMBER},               // projection
        PhoneLookup.LOOKUP_KEY+"=?",                  // selection
        new String[]{lookupKey},                        // selection args
        null);

I get java.lang.IllegalArgumentException: Unknown URL
content://com.android.contacts/phone_lookup

This seems to be related to this issue http://code.google.com/p/android/issues/detail?id=4446
I am not sure though if contact's phone number should be accessed this
way.

It is good if you change API to make it more featureful though having
a documentation with a working example for this use case would be
really helpful.

Best,
Lukasz

On Nov 18, 7:30 am, Bonifaz <bonifaz.kaufm...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bonifaz  
View profile  
 More options Dec 2, 12:29 am
From: Bonifaz <bonifaz.kaufm...@gmail.com>
Date: Tue, 1 Dec 2009 21:29:52 -0800 (PST)
Local: Wed, Dec 2 2009 12:29 am
Subject: Re: Accessing contact's phone numbers
I still don't know how to query Facebook contacts and their phone
numbers.
Could please someone give me a hint about this. If I query
Contacts.CONTENT_URI, it returns all contacts but not Facebook
contacts.

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitri Plotnikov  
View profile  
 More options Dec 2, 12:41 am
From: Dmitri Plotnikov <dplotni...@google.com>
Date: Tue, 1 Dec 2009 21:41:54 -0800
Local: Wed, Dec 2 2009 12:41 am
Subject: Re: [android-developers] Re: Accessing contact's phone numbers

Just to clarify the Facebook question: the FB contact data is not visible to
any applications except a handful of built-in apps like Contacts.  That's a
policy decision by Facebook.

At the same time, any application can read and write data from all other
types of accounts, including Google and Exchange (aka Corporate)

Thanks,
Dmitri

On Dec 1, 2009 9:31 PM, "Bonifaz" <bonifaz.kaufm...@gmail.com> wrote:

I still don't know how to query Facebook contacts and their phone
numbers.
Could please someone give me a hint about this. If I query
Contacts.CONTENT_URI, it returns all contacts but not Facebook
contacts.

-- You received this message because you are subscribed to the Google Groups
"Android Developers" ...


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bonifaz  
View profile  
 More options Dec 2, 9:09 pm
From: Bonifaz <bonifaz.kaufm...@gmail.com>
Date: Wed, 2 Dec 2009 18:09:03 -0800 (PST)
Local: Wed, Dec 2 2009 9:09 pm
Subject: Re: Accessing contact's phone numbers
Thank you Dmitri,

this answer saves me a lot of time.

On Dec 2, 12:41 am, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
romain dereumaux  
View profile  
 More options Dec 4, 8:45 am
From: romain dereumaux <romain.dereum...@gmail.com>
Date: Fri, 4 Dec 2009 05:45:20 -0800 (PST)
Local: Fri, Dec 4 2009 8:45 am
Subject: Re: Accessing contact's phone numbers
But what about the

java.lang.IllegalArgumentException: Unknown URL content://com.android.contacts/phone_lookup
???

On 3 déc, 04:09, Bonifaz <bonifaz.kaufm...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stanlick  
View profile  
 More options Dec 4, 10:12 am
From: stanlick <stanl...@gmail.com>
Date: Fri, 4 Dec 2009 07:12:53 -0800 (PST)
Local: Fri, Dec 4 2009 10:12 am
Subject: Re: Accessing contact's phone numbers
Hey Dmitri --

My app *is* reading FB names/numbers!  Is this an indirect feature on
account of them being imported/sync'd?

Peace,
Scott

On Dec 1, 11:41 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
stanlick  
View profile  
 More options Dec 4, 10:17 am
From: stanlick <stanl...@gmail.com>
Date: Fri, 4 Dec 2009 07:17:07 -0800 (PST)
Local: Fri, Dec 4 2009 10:17 am
Subject: Re: Accessing contact's phone numbers
scratch that!  She was a GMail contact.  Damn.

On Dec 4, 9:12 am, stanlick <stanl...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ghassett  
View profile  
 More options Dec 4, 7:00 pm
From: ghassett <greghass...@gmail.com>
Date: Fri, 4 Dec 2009 16:00:52 -0800 (PST)
Local: Fri, Dec 4 2009 7:00 pm
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Hi Dmitri -- I am not sure that the old API is still functional.  I am
using what I think is the standard way of getting a display name from
a phone number -- see the code below -- and it functions on a 1.6
emulator but on on a 2.0 emulator.  Am I doing something wrong?  Is
there an example somewhere of how to "get a contact name from a phone
number" that will function in 1.5, 1.6, and 2.0?

Here's the code -- it works when run in the 1.6 emulator, but not in
the 2.0 emulator (Cursor comes back non-null, but there are no records
so moveToFirst returns false):

        public String getDisplayName (ContentResolver contentResolver)
        {
                String retval = mPhoneNumber;

                Cursor cursor = contentResolver.query(
                                Uri.withAppendedPath (Contacts.Phones.CONTENT_FILTER_URL,
Uri.encode(mPhoneNumber)),
                                new String[] { Contacts.Phones.DISPLAY_NAME },
                                null, null, null);

                if (cursor != null  &&  cursor.moveToFirst())
                {
                        retval = cursor.getString(0);
                }

                return retval;
        }

// thanks // greg //

On Oct 30, 3:05 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "[Android 2.0] Accessing contact's phone numbers" by Dmitri Plotnikov
Dmitri Plotnikov  
View profile  
 More options Dec 4, 7:21 pm
From: Dmitri Plotnikov <dplotni...@google.com>
Date: Fri, 4 Dec 2009 16:21:09 -0800
Local: Fri, Dec 4 2009 7:21 pm
Subject: Re: [android-developers] Re: [Android 2.0] Accessing contact's phone numbers
Hi Greg,

Take a look at the testPhonesFilterQuery unit test we have for
verifying the behavior in question:

http://android.git.kernel.org/?p=platform/packages/providers/Contacts...

Is what it's doing correct? Is it different from what you are doing?

Thank you,
- Dmitri


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Accessing contact's phone numbers" by ghassett
ghassett  
View profile  
 More options Dec 5, 11:36 am
From: ghassett <greghass...@gmail.com>
Date: Sat, 5 Dec 2009 08:36:26 -0800 (PST)
Local: Sat, Dec 5 2009 11:36 am
Subject: Re: [Android 2.0] Accessing contact's phone numbers
Yes Dmitri, this is exactly what I am doing -- I am not manually
inserting records into the contacts db like the test case does, but
there is definitely a contact with a mobile phone number
"617939xxxx" (with real digits, not "x"s), and when I open a cursor on
the query:

Uri filterUri1 = Uri.withAppendedPath(Phones.CONTENT_FILTER_URL,
"617939xxxx"); // with real digits, not "x"s

I get back a valid cursor, but no rows (moveToFirst() returns false)
-- on 2.0 emulator only.  On 1.6 emulator, it works fine.

// greg //

On Dec 4, 7:21 pm, Dmitri Plotnikov <dplotni...@google.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 30   Newer >
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google