I'm having a hellva time just getting the name and phone # from the ContactsContract.Contacts... I realize they updated the API but I'm banging my head against the wall here. I put my code below with the OnClickListener and OnStartActivity... The name comes fine but I can't get the number... Been banging my head for 4 hours on this and searched everywhere. Can someone throw me a bone?
public void onClick(View arg0) {
// TODO Auto-generated method stub
switch(arg0.getId()){
case R.id.bCallContacts:
Intent i = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(i, PICK_CONTACT);
break; }
private Cursor getContact(Uri uri) {
// Run query
Cursor c = managedQuery(uri, null, null, null, null);
return c;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent
data)
{
super.onActivityResult(requestCode, resultCode, data);
Cursor c = getContact(data.getData());
if (c.moveToFirst())
{
String name =
c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME) );
callName.setText(name);
String phoneNumber = c.getString(c.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
callNum.setText(phoneNumber);
}
}