Xamarin.Forms.Contacts icon indicating copy to clipboard operation
Xamarin.Forms.Contacts copied to clipboard

Problem when call GetContactsListAsync() on Android

Open mcferdev opened this issue 6 years ago • 4 comments

Was working but now the app is crashing... it seems like the call await Plugin.ContactService.CrossContactService.Current.GetContactListAsync() its returning nothing on my mobile phone. I am using the latest version of this plugin on a Galaxy S8 with Android 8.

My app is on Stores...was working fine. Now, stopped just on Android... I am trying to debug but when I call GetContactListAsync(), seems like the execution is not called... goes fast to the next line and the result is null.

mcferdev avatar Feb 11 '19 15:02 mcferdev

I alto tried on another Mobile phone Nexus 5 with android 5.0 and its not working.

mcferdev avatar Feb 12 '19 00:02 mcferdev

@marcelocferdeveloper is your issue solved. Please let me know i am also facing the same issue it s working fine in Android version 4.4 but when i debug in Android 6.0 getting error like Java.Lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{2ea4c29 2991:com.companyname.FormsApplication/u0a73} (pid=2991, uid=10073) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS.

Please help me Thanks. if you have any alternative solution pls let me know.

Awaiting for your reply.

chinni-nag avatar Aug 26 '19 16:08 chinni-nag

HI, even i am facing the issue in my android device (9.0) .

Java.Lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{2ea4c29 2991:com.companyname.FormsApplication/u0a73} (pid=2991, uid=10073) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS.

Any solution ??

uday-lucky avatar Nov 20 '19 11:11 uday-lucky

You can't aquire the permission automatically anymore. Only the user can grant it. You can just request the permission on Android 9:

if (ActivityCompat.CheckSelfPermission(Application.Context, Android.Manifest.Permission.ReadContacts) != Android.Content.PM.Permission.Granted)
{
    ActivityCompat.RequestPermissions(activity, new String[] { Android.Manifest.Permission.ReadContacts }, 140);
}

Adrianotiger avatar Dec 10 '19 14:12 Adrianotiger