Contacts activity doesn't return data
Posted
by
Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2011-01-05T02:28:24Z
Indexed on
2011/01/05
2:53 UTC
Read the original article
Hit count: 181
In my app I simply open the list of activities and when a contact is clicked I attempt to retrieve the name of the contact selected and put it into a string. The app crashes in the onActivityResult() function. I do have the READ_CONTACTS permission set.
/**
* Opens the contacts activity
*/
public void openContacts() {
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
switch (reqCode) {
case (PICK_CONTACT) :
if (resultCode == Activity.RESULT_OK) {
Uri contactData = data.getData();
Cursor c = managedQuery(contactData, null, null, null, null); //NullPointerException thrown here, line 102
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndexOrThrow(People.NAME));
FRIEND_NAME = name;
showConfirmDialog(name);
}
}
break;
}
}
The following logcat error logs are returned:
Any help is appreciated.
Thanks
© Stack Overflow or respective owner