0
我正在通過ContactsContract
執行查詢以檢索聯繫人詳細信息(特別是其郵遞地址)。問題的關鍵是,我想跳過那些來自例如WhatsApp,LinkedIn,Skype和其他應用程序同步通訊錄...查詢聯繫人詳細信息跳過其他應用程序的同步聯繫人
我的代碼是:
Uri uri = StructuredPostal.CONTENT_URI;
String[] sqlSelect = new String[] { StructuredPostal.FORMATTED_ADDRESS, StructuredPostal.DISPLAY_NAME, StructuredPostal.STREET, StructuredPostal.CITY, StructuredPostal.POSTCODE, StructuredPostal.COUNTRY };
String sqlWhere = StructuredPostal.MIMETYPE + "=?" + " AND " +
"(" + StructuredPostal.STREET + " LIKE '%" + queryString + "%'" + " OR " +
StructuredPostal.CITY + " LIKE '%" + queryString + "%'" + " OR " +
StructuredPostal.POSTCODE + " LIKE '%" + queryString + "%'" + " OR " +
StructuredPostal.COUNTRY + " LIKE '%" + queryString + "%')";
String[] sqlWhereParams = new String[]{ StructuredPostal.CONTENT_ITEM_TYPE };
String sortOrder = StructuredPostal.STREET + " ASC";
Cursor cursor = this.getContentResolver().query(uri, sqlSelect, sqlWhere, sqlWhereParams, sortOrder);
if (cursor.moveToFirst()) {
do {
String formattedAddress = cursor.getString(cursor.getColumnIndex(StructuredPostal.FORMATTED_ADDRESS));
String displayName = cursor.getString(cursor.getColumnIndex(StructuredPostal.DISPLAY_NAME));
String street = cursor.getString(cursor.getColumnIndex(StructuredPostal.STREET));
String city = cursor.getString(cursor.getColumnIndex(StructuredPostal.CITY));
String postcode = cursor.getString(cursor.getColumnIndex(StructuredPostal.POSTCODE));
String country = cursor.getString(cursor.getColumnIndex(StructuredPostal.COUNTRY));
Log.d(TAG, formattedAddress + " " + displayName + " " + street + " " + city + " " + postcode + " " + country);
} while (cursor.moveToNext());
}
的LogCat
輸出正確打印聯繫人我在地址簿中手動添加:
<postal_address> <contact_full_name> <street> <city> <postcode> <country>
但正在印製像(LinkedIn)從第三方應用程序導入的聯繫人:
<email> <contact_full_name> <email> null null null
應在何處(如果郵寄地址是不可用):
null <contact_full_name> null null null null
是使用不當接觸的第三方應用程序?有什麼方法可以跳過第三方同步的聯繫人嗎?