Android: strange thing about loading contact info -



Android: strange thing about loading contact info -

i created app. working on htc want hd, when tested on zte blade, unusual problem appeared. in app when user selects contact name spinner menu appears. in menu user can send sms user, phone call him/her or @ his/her contact info. on htc want hd, working fine. on zte there seems exasperating problem contact info button: in cases when user selects contact , wants see contact info, other contact's info shown. select pete spinner dave's contact info. in other cases select tom spinner , tom's contact info. problem not existing on htc. couldn't figure out causes problem. way, contact list on htc populated gmail , facebook , app still working fine, while contact list of zte has never seen gmail or facebook accounts (i not exclusively sure this).

this code using contact info:

infobtn.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { contentresolver cr = getcontentresolver(); cursor cur = cr.query(contactscontract.contacts.content_uri, null, null, null, null); if (cur.getcount() > 0) { while (cur.movetonext()) { id_contact = cur.getstring(cur.getcolumnindex(contactscontract.contacts._id)); name_contact = cur.getstring(cur.getcolumnindex(contactscontract.contacts.display_name)); if (name_contact.equals(name1)) { cursor pcur = cr.query( contactscontract.commondatakinds.phone.content_uri, null, contactscontract.commondatakinds.phone.contact_id +" = ?", new string[]{id_contact}, null); id_contact2 = id_contact; while (pcur.movetonext()){ } pcur.close(); } } intent intent_contacts = new intent(intent.action_view, uri.parse("content://contacts/people/" + id_contact2)); startactivity(intent_contacts); } } });

i have similar problems in application. app widget give possibility utilize favorites contacts in fast way. user creates new widget , assigns contact it. when clicks on widget able create mutual contact actions - call, sms, edit, etc.

some users send study one: "i select 4 contacts , app shows 4 1 of them right 3 others same contact didnt picked". "why wrong contact show when picked? on droid incredible"

i can't reproduce problem on side. have tried several different devices, tried create import/export contacts - no results.

anyway, have ideas source of problem.

my application uses lookup keys store contacts, according sdk. so, when user picks contact, application stores contact lookup key. uses lookup key contact id contact. after that, uses received contact id in other functions. function - uses contact id in sub-query.

the question is: possible different contacts (with different lookup keys) have same contact id? looks it's possible on devices in rare cases... if so, need utilize contact id + lookup key identify contact. (update: suggestion incorrect. lookup key can changed after contact info modification, won't find contact).

as understand, able reproduce problem on side. suggest alter code in such way:

infobtn.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { contentresolver cr = getcontentresolver(); cursor cur = cr.query(contactscontract.contacts.content_uri, null, null, null, null); if (cur.getcount() > 0) { while (cur.movetonext()) { id_contact = cur.getstring(cur.getcolumnindex(contactscontract.contacts._id)); name_contact = cur.getstring(cur.getcolumnindex(contactscontract.contacts.display_name)); string lookup_key = cur.getstring(cur.getcolumnindex(contactscontract.contacts.lookup_key)); if (name_contact.equals(name1)) { cursor pcur = cr.query( contactscontract.commondatakinds.phone.content_uri, null, contactscontract.commondatakinds.phone.contact_id +" = ? , " + contactscontract.commondatakinds.phone.lookup_key + " = ?", new string[]{id_contact, lookup_key}, null); id_contact2 = id_contact; while (pcur.movetonext()){ } pcur.close(); } } intent intent_contacts = new intent(intent.action_view, uri.parse("content://contacts/people/" + id_contact2)); startactivity(intent_contacts); } } });

and seek reproduce problem again.

android contact

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -