Xamarin.Forms.Contacts
Xamarin.Forms.Contacts copied to clipboard
Problem when call GetContactsListAsync() on Android
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.
I alto tried on another Mobile phone Nexus 5 with android 5.0 and its not working.
@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.
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 ??
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);
}