【发布时间】:2016-02-22 13:05:16
【问题描述】:
我有一个数组列表。
1) 我的第一个 ArrayList<String> some_num = new ArrayList<String>(); 包含这样的值。
[1111111111, 2222222222]
现在我正在尝试将其与我的移动联系人进行比较。
Uri uri = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER};
Cursor people = getActivity().getContentResolver().query(uri, projection, null, null, null);
int indexName = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
int indexNumber = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
int j_count=0;
String number;
people.moveToFirst();
do {
String name = people.getString(indexName);
number = people.getString(indexNumber);
j_count++;
// Do work...
} while (people.moveToNext());
for(int j=0;j<=j_count;j++){
if (some_num.contains(number)){
// do nothing
}
else{
Log.e("num",number);
}
}
我正在尝试从手机电话簿中获取我的 ArrayList 中不存在的那些号码。我知道在 for 条件下我必须获取数组的值,但是当我尝试这样做时,我没有得到我的其余联系人。
提前致谢
【问题讨论】:
-
你在这段代码中遇到了什么问题,有什么异常或错误吗?
-
不,我只有一个联系人
标签: android arraylist android-contacts