private String getContacts(Object parameters) {
JSONArray peopleJSON = new JSONArray();
Cursor tempContactsCursor = AndroidBaseActivity.self
.getContentResolver().query(Contacts.People.CONTENT_URI, null,
null, null, null);
if (tempContactsCursor.moveToFirst()) {
do {
JSONObject jsonPeopleNumbers = new JSONObject();
// 获得联系人的ID号
int idColumn = tempContactsCursor
.getColumnIndex(Contacts.People._ID);
int peopleNameIndex = tempContactsCursor
.getColumnIndex(Contacts.People.DISPLAY_NAME);
int mobileNumberIndex = tempContactsCursor
.getColumnIndex(Contacts.Phones.NUMBER);
String id = tempContactsCursor.getString(idColumn);
String name = tempContactsCursor.getString(peopleNameIndex);
try {
jsonPeopleNumbers.put("mobile", tempContactsCursor
.getString(mobileNumberIndex));
jsonPeopleNumbers.put("name", name);
jsonPeopleNumbers.put("id", id);
} catch (JSONException e) {
e.printStackTrace();
}
peopleJSON.put(jsonPeopleNumbers);
} while (tempContactsCursor.moveToNext());
tempContactsCursor.close();
}
return peopleJSON.toString();
}
详细解决方案
android1.5取得所有联系人ID,人名,默认移动电话号码,并生成 JSONArray数据
热度:450 发布时间:2012-08-29 08:40:14.0
相关解决方案
- 为何执行到JSONArray distJson=JSONArray.fromObject(distList);就不执行了
- 为啥执行到JSONArray distJson=JSONArray.fromObject(distList);就不执行了
- JsonArray: There is a cycle in the hierarchy! 有关问题解决
- 关于json的操作 jsonArray-jsonObject
- android1.5取得所有联系人ID,人名,默认移动电话号码,并生成 JSONArray数据
- JSONObject 与 JSONArray 的运用
- 为什么执行到JSONArray distJson=JSONArray.fromObject(distList);就不执行了,该如何解决
- JSONArray.fromObject 奇怪现象解决方法
- SQL server 2008,有表bm,要建新表bmm,并引出bm中的列:姓名、电话号码,求语句
- SQL server 2008,有表bm,要筑新表bmm,并引入bm中的列:姓名、电话号码,求语句
- 关于String json = JSONArray.fromObject(list).toString();出错
- Object cannot be converted to JSONArray,该如何处理
- How to put this JSONArray into an Android ListView,该如何解决
- Android1.5汉语言文档
- android1.1(以上架),如何文章不能删了,请管理员删掉它
- android1.5后 视频的预览图怎么实现?(分不多了见谅)~
- 正则表达式之(年龄)(电话号码)(姓名)
- 20. 电话号码
- C/C++编程题刷题:电话号码