i have issue with contact's IM values retrieving.
Interesting that under emulator all works fine, but on real device (G1) - is not.
Can you please help me with resolving this problem (may be i missed something)? Thanks in advance!
Here is my source how i make retrieving:
Using java Syntax Highlighting
- void retreiveMessengers()
- {
- String where = Contacts.ContactMethods.PERSON_ID + " = " + person_id + " AND " +
- Contacts.ContactMethods.KIND + " = " + Contacts.KIND_IM;
- String[] messengersProjection = new String[] {Contacts.ContactMethods.KIND, Contacts.ContactMethods.TYPE, Contacts.ContactMethods.DATA, Contacts.ContactMethods.AUX_DATA};
- Cursor messengersCursor = null;
- messengersCursor = content_resolver.query(Contacts.ContactMethods.CONTENT_URI, messengersProjection, where, null, null);
- int messengersCursorCount = messengersCursor.getCount();
- if (messengersCursorCount > 0)
- {
- messengersCursor.moveToFirst();
- int kindColumn = messengersCursor.getColumnIndex(Contacts.ContactMethods.KIND);
- int typeColumn = messengersCursor.getColumnIndex(Contacts.ContactMethods.TYPE);
- int dataColumn = messengersCursor.getColumnIndex(Contacts.ContactMethods.DATA);
- int auxDataColumn = messengersCursor.getColumnIndex(Contacts.ContactMethods.AUX_DATA);
- for (int i = 0; i < messengersCursorCount; i++)
- {
- switch (messengersCursor.getInt(kindColumn))
- {
- case Contacts.KIND_IM:
- int protocol = -1;
- Object protocolObj = Contacts.ContactMethods.decodeImProtocol(messengersCursor.getString(auxDataColumn));
- if (protocolObj != null)
- {
- if (protocolObj instanceof Number)
- {
- protocol = ((Number)protocolObj).intValue();
- }
- }
- switch (protocol)
- {
- case Contacts.ContactMethods.PROTOCOL_AIM:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_GOOGLE_TALK:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_ICQ:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_JABBER:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_MSN:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_QQ:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_SKYPE:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- case Contacts.ContactMethods.PROTOCOL_YAHOO:
- chat_value = messengersCursor.getString(dataColumn);
- break;
- }
- break;
- }
- messengersCursor.moveToNext();
- }
- }
- messengersCursor.close();
- }
Parsed in 0.043 seconds, using GeSHi 1.0.8.4
Thanks for help.
Regards,
Vadym

