I ran into a problem with the new contacts API today that other developers may end up encountering. I bought a Droid and had the contacts from an old phone (not an Android phone) moved over at the store. I'm not sure how they moved over the contacts, but they never linked the phone to a Google account so when I tried to run my app on the phone it could not see any of the contacts. Once I linked to a Google account and added new contacts I could see those contacts with my app but still could not see the transfered contacts. It seems like Google's solution of allowing the legacy contact API to access only the first account does not work in this case. This will likely break some apps for users who move over their contacts in this way. I did come up with a quick solution for my app that seems to solve the problem (at least in the emulator, haven't tried the real phone yet):
This code allows the user to pick a phone number from a list of all numbers on the phone. It checks to see if the ContactsContract class exists and if so uses the new URI for phone numbers. Otherwise it uses the old URI. This seems to work for Android 2.0 and also previous versions though I'm not sure if it is the best solution. Anyone have a better way? Intent intent = null; ClassLoader classLoader = DialerContactList.class.getClassLoader(); try { classLoader.loadClass("android.provider.ContactsContract"); intent = new Intent(Intent.ACTION_PICK,Uri.parse("content:// com.android.contacts/data/phones")); } catch (ClassNotFoundException e) { } if (intent == null) { intent = new Intent(Intent.ACTION_PICK,Phones.CONTENT_URI); } startActivityForResult(intent, ADD_CONTACT); On Nov 7, 11:16 am, Ravi <textlo...@gmail.com> wrote: > Hi Dmitri, > This thread is very helpful and thank you for taking time - believe me > I really appreciate your help. > Is there any plan that you are aware of that google would publish > contacts changes rather than bugging people on groups for the select > knolege of supposed to be opensource system ? -- 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