解决方案 »
- 问问,如何使用HTTP的代理方式连接?
- How can i know current thread id without call myTid() when break?
- 关于PULL 解析XML 想得到question结点下的内容 求高手
- 游戏编程中坐标转换的问题
- Service 生命周期
- Android 关于蓝牙mic和speaker的输入输出
- android图表问题
- Android google map 开发 ,求帮助!!!!!!
- 关于图像识别-Tesseract-OCR
- 开发Android app如何应用Drools
- Android图标比别人的小是怎么回事
- android震动的参数怎么设置
private AsyncQueryHandler asyncQuery;
/**
* 读取通讯录
*/
private void readContacts(){
asyncQuery = new ContactAsyncQueryHandler(getContentResolver());
Uri uri = Uri.parse("content://com.android.contacts/data/phones");
String[] projection = { "_id", "display_name", "data1", "sort_key" };
asyncQuery.startQuery(0, null, uri, projection, null, null,
"sort_key COLLATE LOCALIZED asc");
}
//异步查询联系人
private class ContactAsyncQueryHandler extends AsyncQueryHandler {
public ContactAsyncQueryHandler(ContentResolver cr) {
super(cr);
}
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
if (cursor != null && cursor.getCount() > 0) {
ArrayList<CallsItem> list = new ArrayList<CallsItem>();
cursor.moveToFirst();
for (int i = 0; i < cursor.getCount(); i++) {
CallsItem item = new CallsItem();
cursor.moveToPosition(i);
String name = cursor.getString(1);
String number = cursor.getString(2);
String sortKey = cursor.getString(3);
if (number.startsWith("+86")) {
number = number.substring(3); //去掉+86
}
item.name = name;
item.number = number;
item.sort = sortKey;
list.add(item);
// System.out.println("name:" + name + " number:" + number + " sort:" + sortKey);
}
app.allList = list;
}
}
}