【发布时间】:2012-01-09 12:31:19
【问题描述】:
我正在尝试在 Android 的通讯录中实现人员查找。这就是我的实现方式:
Cursor cur = this.context.getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, null, Data.DISPLAY_NAME + "=?", new String[] { mKey }, null);
if (cur.moveToFirst()) {
Intent n = new Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
((Activity) this.context).startActivityForResult(n, PICK_REQUEST);
if (PICK_REQUEST != 0) {
if (Activity.RESULT_OK != 0) {
((Activity) this.context).startActivity(n);
}
}
} else {
Toast.makeText(this.context, "The contact does not exist", Toast.LENGTH_LONG).show();
// }
其中mKey 是要搜索的人的值。当我点击搜索时,似乎什么都没有发生。做错了什么?请指教。
谢谢。
【问题讨论】:
-
startActivityForResult后面不应该有任何代码。您需要覆盖onActivityResult。谷歌(或等待有人在答案中编写代码)
标签: android android-intent android-contacts android-activity