Vote count:
0
I query the specific contact_id, and I got many same numbers. Later, found out that the cause of multiple accounts. I want to combine mulitple account to a single one. How?
Here is how I get the numbers.
public Map<Long, ArrayList<String>> getAllNumbers(long[] contactId){
Map<Long, ArrayList<String>> result = new HashMap<Long, ArrayList<String>>();
for (long id : contactId){
Log.d("same_contact", "_____________");
Uri methodUri = getMethodUri(getContactUri(id));
Cursor cursor = null;
try {
cursor = mContext.getContentResolver().query(methodUri,
ContactsDBReader.DATA_PROJECTION, null, null, null);
if (cursor != null && cursor.getCount() > 0) {
boolean isTrue = cursor.moveToFirst();
ArrayList<String> phones = new ArrayList<String>();
while (isTrue){
String mime = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.MIMETYPE));
if (ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE.equals(mime)) {
final String phoneNumber = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
if(phoneNumber != null && phoneNumber.length() > 0){
phones.add(phoneNumber);
Log.d("same_contact", "phoneNumber " + phoneNumber);
}
}
isTrue = cursor.moveToNext();
}
if(phones != null && phones.size() > 1){
result.put(id, phones);
}
}
}finally {
if(cursor != null){
cursor.close();
}
}
Log.d("same_contact", "_____________");
}
return result;
}
Try to combine the same "phones" from different account in "result"
asked 3 mins ago
Aucun commentaire:
Enregistrer un commentaire