' Activity.ManagedQuery(Uri,string [],string,string [],string)'已经过时了:'已弃用'

时间:2017-03-14 14:07:24

标签: c# android xamarin xamarin.android

我在为Xamarin.Android编译此代码时收到了此消息:

"E:\_MyFiles\Projects\C#\TelegramHack\TelegramHack.csproj" (SignAndroidPackage target) (1) ->
(CoreCompile target) ->
  App.cs(53,26): warning CS0618: 'Activity.ManagedQuery(Uri, string[], string, string[], string)' is obsolete: 'deprecated'
[E:\_MyFiles\Projects\C#\**PrivateContent**\**PrivateContent**.csproj]

var ctks = new List<Contact>();
            var uri = ContactsContract.CommonDataKinds.Phone.ContentUri;
            string[] projection = { ContactsContract.Contacts.InterfaceConsts.Id, ContactsContract.Contacts.InterfaceConsts.DisplayName, ContactsContract.CommonDataKinds.Phone.Number};
            var cursor = ManagedQuery(uri, projection, null, null, null);
            if (cursor.MoveToFirst ()) {
                do {
                        ctks.Add(new Contact {Name = cursor.GetString(cursor.GetColumnIndex (projection [1])), Number = cursor.GetString(cursor.GetColumnIndex (projection [2]))});
                }  while (cursor.MoveToNext());
            }
            return ctks.ToArray();

0 个答案:

没有答案