0
我在Xamarin中开发c#并试图获取联系人的号码。我试过这样:获取联系人的号码
private static int PICK_NUMAR = 1;
private void Click (object sender , EventArgs eventArgs)
{
Intent intent = new Intent (Intent.ActionPick , Android.Net.Uri.Parse ("content://contacts"));
intent.SetType (ContactsContract.Contacts.ContentType);
StartActivityForResult (intent , SMS_Send.PICK_NUMAR);
}
protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
{
if ((requestCode == SMS_Send.PICK_NUMAR) && (resultCode == Result.Ok) && (data != null)) {
Android.Net.Uri uri = data.Data;
string[] projection = new [] { ContactsContract.CommonDataKinds.Phone.Number };
using (Android.Database.ICursor c = ManagedQuery (uri, projection, null, null, null)) {
if (c != null) {
string NUMAR_TELEFON = c.GetString (c.GetColumnIndex (ContactsContract.CommonDataKinds.Phone.Number));
c.MoveToFirst();
FindViewById<EditText> (Resource.Id.Input2).Text = NUMAR_TELEFON;
}
}
}
}
但没有奏效。我试图进行调试,并且在ICursor的声明后我看到代码卡住了。我做错了什么?