が続く可能性がDELETE
MOVED_TO
、または続いMOVED_FROM
から、それを検出します:
/**
* Retrieves the contact information.
*/
@Override
public ContactInfo loadContact(ContentResolver contentResolver, Uri contactUri) {
ContactInfo contactInfo = new ContactInfo();
long contactId = -1;
// Load the display name for the specified person
Cursor cursor = contentResolver.query(contactUri,
new String[]{Contacts._ID, Contacts.DISPLAY_NAME}, null, null, null);
try {
if (cursor.moveToFirst()) {
contactId = cursor.getLong(0);
contactInfo.setDisplayName(cursor.getString(1));
}
} finally {
cursor.close();
}
// Load the phone number (if any).
cursor = contentResolver.query(Phone.CONTENT_URI,
new String[]{Phone.NUMBER},
Phone.CONTACT_ID + "=" + contactId, null, Phone.IS_SUPER_PRIMARY + " DESC");
try {
if (cursor.moveToFirst()) {
contactInfo.setPhoneNumber(cursor.getString(0));
}
} finally {
cursor.close();
}
return contactInfo;
}
あなたはCursor cursor = contentResolver.query(contactUri, new String[]{Contacts._ID, Contacts.DISPLAY_NAME}, null, null, null);
列名がhttp://developer.android.com/reference/android/provider/ContactsContract.Contacts.htmlに記載されており、サンプルを見て、それがここにcursor.getLong(0)
を思わあなたが探しているのコンタクトIDであると盗んする連絡先の列を指定することができます。連絡先がどのように編集され、他のユーザーが追加されたかによっても変化するようですが、そのようなケースも処理できるはずです。
うわー:まっすぐに穴に!どうもありがとうございました。コメントはありません:) – CoolStraw
probsはありません。実際には、これらの操作を何らかの形で妨げたり影響を与えたりすることは実際にはできないということを指摘しておく価値があります。伝統的な意味でのフックではありません。 – RivieraKid
十分に公正で、私はそれ以上のものを必要としません、単純な通知はちょうど完璧です:)。ありがとうございました;) – CoolStraw