从REQUEST_CONTACTPICKER中选择联系人时应用程序崩溃

时间:2014-06-25 20:32:09

标签: java android contacts

关注this solution我遇到了代码问题。每当我从弹出的列表中选择一个联系人时,该应用程序都会强制关闭。有些东西告诉我罪魁祸首与我在logcat中找到的东西有关。

这是我的代码版本:

     public void onActivityResult(int reqCode, int resultCode, Intent data) {

    super.onActivityResult(reqCode, resultCode, data);

    switch (reqCode) {
        case (1) :
            if (resultCode == Activity.RESULT_OK) {
                Uri contactData = data.getData();
                Cursor cursor =  managedQuery(contactData, null, null, null, null);
                cursor.moveToFirst();
                String name = cursor.getString(cursor.getColumnIndexOrThrow(Contacts.People.NAME));
                String number = cursor.getString(cursor.getColumnIndexOrThrow(Contacts.People.NUMBER));
                name1.setText(name);
                num1.setText(number);
            }
            break;
    }
}

Take a look at the logcat

0 个答案:

没有答案