android - Matching incoming and outgoing phone numbers -
i'm making sms viewing application , using contentresolver obtain sms messages on phone (yes, understand risks). other applications, want group messages same person 1 thread, display latest message them, , order contacts date of last message.
when comes address values of incoming messages, contain country code (e.g. +44123456789). when user saves contacts, ignore country code , type in local format. outgoing messages stored 0123456789.
so, database contain same address in both formats, +44123456789 , 0123456789. how match 2 , remove duplicate address?
note: 1) messages same person may not have same "thread id" 2) there may not "contact id"/"display name" value address
actually, messages , same contact in same thread, therefore have same thread_id. (apart multiple recipient messages, in own thread).
by looking in content://sms , storing list of obtained thread_ids can make sure there's no duplicates. address value can use following code obtain display name.
now, i'm trying optimise this:
private string quickcallerid(string phonenumber){ uri uri = uri.withappendedpath(phonelookup.content_filter_uri, uri.encode(phonenumber)); contentresolver resolver=getcontentresolver(); cursor cur = resolver.query(uri, new string[]{phonelookup.display_name}, null, null, null); if(cur!=null&&cur.movetofirst()){ string value=cur.getstring(cur.getcolumnindex(phonelookup.display_name)); if(value!=null){ cur.close(); return value; } } cur.close(); return ""; }
Comments
Post a Comment