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