[mono-android] selecting contacts
John Murray
john at murray.gb.com
Thu Mar 31 14:30:11 EDT 2011
Hello all
sorry to be 'needy' but this might help other beginners as well - could
form a useful how-to if I could get it working
I have got a fair way in working out how to select a contact from the
contacts database with following code
This works up to a point
private void butt1click()
{
// clicking this button calls up a list of contacts from the phone
successfully
Intent intent = new Intent(Intent.ActionPick);
intent.SetType(ContactsContract.Contacts.ContentType);
StartActivityForResult(intent, 5555);
}
// this on activityresult is intended to return something useful from the
selection e1 is an EditText on the calling view
public void OnActivityResult(int requestCode, int resultCode, Intent
intent)
{
// if (requestCode == 5555)
// {
ICursor cursor = ManagedQuery(intent.Data, null, null, null,
null);
cursor.MoveToNext();
string name = "some name";
name =
cursor.GetString(cursor.GetColumnIndexOrThrow(ContactsContract.ContactsColum
nsConsts.DisplayName));
e1.Text = name;
// }
}//onActivityResult
Works well - I get the contact selection dialog
But it seems to completely ignore the OnActivityResult method
I have another childwindow dialog which uses same approach but in another
activity - should I just have one OnActivity method ? I thought not as this
contacts picker is called from a completely different view and activity than
the other one
Any ideas why the OnActivityResult seems to be bypassed - you can see I
remmed out the result code in case that was it
TIA
John Murray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110331/d810658a/attachment-0001.html
More information about the Monodroid
mailing list