我正在开发一个需要获取联系人列表的应用。得到所有联系需要时间。所以我想在本地存储联系人列表。但是我需要在手机中添加新联系人时更新。如何通知我的应用程序新添加的联系人添加到设备? 我使用此代码与设备联系:`
public void getContact()
{
ContentResolver cr = getContentResolver();
Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,
null, null, null, null);
Log.e("curcouuntLOL",cur.getCount()+"");
if (cur.getCount() > 0) {
while (cur.moveToNext()) {
String id = cur.getString(
cur.getColumnIndex(ContactsContract.Contacts._ID));
String name = cur.getString(cur.getColumnIndex(
ContactsContract.Contacts.DISPLAY_NAME));
String photoUri = cur.getString(cur.getColumnIndex(ContactsContract.Contacts.PHOTO_THUMBNAIL_URI));
if (Integer.parseInt(cur.getString(cur.getColumnIndex(
ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
modelPhone=new ModelPhone();
Cursor pCur = cr.query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID +" = ?",
new String[]{id}, null);
while (pCur.moveToNext()) {
String phoneNo = pCur.getString(pCur.getColumnIndex(
ContactsContract.CommonDataKinds.Phone.NUMBER));
Toast.makeText(PhoneNumberlistActivity.this, "Name: " + name
+ ", Phone No: " + phoneNo +" ,photoUri :" + photoUri, Toast.LENGTH_SHORT).show();
}
pCur.close();
}
}
}
}`
答案 0 :(得分:-1)
这样你可以:
opengl32.lib