[mono-android] selecting contacts

hdortim hdortim at gmx.net
Thu Mar 31 14:48:45 EDT 2011


Hi John,

I am not sure, but I have used OnActivityResult() succesfully, but you 
need to override the method to make sure it is called.
So your Method shoudl look like this:
public override void OnActivityResult(int requestCode, int resultCode, 
Intent intent)

{

...
}

Have fun,

H. Dortim


Am 31.03.2011 20:30, schrieb John Murray:
>
> 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
>
> privatevoid 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.ContactsColumnsConsts.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
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110331/09f35598/attachment-0001.html 


More information about the Monodroid mailing list