Retrieving a phone number with ContactsContract in Android - function doesn't work

后端 未结 3 1951
渐次进展
渐次进展 2021-01-01 04:08

I wrote the following function in order to retrieve one single phone number that belongs to the contact with id \"contactID\".

The function which is to retri

3条回答
  •  悲&欢浪女
    2021-01-01 04:25

    Your code for getContactPhone() works fine on my end. I tested by launching a contact picker, selecting a contact, then using the ID that was returned and passed that into your method.

    So I suspect you are indeed passing in an invalid ID. Can you post the full stack trace for the null pointer exception?

    Yes, lookup keys are available because _IDs are not guaranteed to stay the same since syncs and contact aggregation changes them.

提交回复
热议问题