I have a widget that will open the contacts list by a phone number. I am using Contacts.Intents.SHOW_OR_CREATE_CONTACT I know it's deprecated but I want this to work on android 1.6. I have a phone number to use on the lookup intent. here is the code
Intent contViewIntent = new Intent(Contacts.Intents.SHOW_OR_CREATE_CONTACT);
contViewIntent.setData(Uri.fromParts("tel", number, null));
PendingIntent contPendIntent = PendingIntent.getActivity(context, 0, contViewIntent, 0);
views.setOnClickPendingIntent(viewID, contPendIntent);
When the Contact list has 2 or more contacts with the same number then this will open the list of contacts and has the user select one. This works fine on 1.6, but on 2.0 and above it shows a list of contacts with just the number 1 or number 2 in the names and when you select one of those from the list to view you get an error.
04-09 19:12:47.891: ERROR/CursorWindow(105): Bad request for field slot 0,6. numRows = 2, numColumns = 6
04-09 19:12:47.992: ERROR/AndroidRuntime(105): java.lang.IllegalStateException: get field slot from row 0 col 6 failed
how do I get this to work on 1.6 and 2.0 above?
Android 2.0 has a completely new API for managing contacts (look up ContactsContract). In my app, I ended up writing the low-level contact management twice - once for 2.0, once for 1.6 and under (I check via reflection to see if the ContactsContract class exists and switch to the 2.0+ code in that case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With