Unity-Contacts-List
Unity-Contacts-List copied to clipboard
App just crashes
public void getContactList() // this function is executed on button click
{
Contacts.LoadContactList(onContactLoadDone, onContactLoadFailed);
}
void onContactLoadFailed(string reason)
{
ContactfailString = reason;
}
void onContactLoadDone()
{
Debug.Log("Contacts loaded");
foreach (GameObject g in ContactLoadedParent)
{
GameObject.Destroy(g);
}
ContactfailString = null;
foreach (Contact c in Contacts.ContactsList)
{
GameObject temp = GameObject.Instantiate(Contactitem, ContactLoadedParent);
Text[] t = temp.GetComponentsInChildren<Text>();
t[0].text = c.Name;
t[1].text = c.Phones[0].Number;
temp.GetComponentInChildren<RawImage>().texture = c.PhotoTexture;
}
}
have modified the manifest as well to include the following permissions
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
but the app still crashes
Hi! Have you found any solutions? What version of android are you running on your app? Make sure your app has permission to access (Read at least) contacts info.
Hi! Have you found any solutions? What version of android are you running on your app? Make sure your app has permission to access (Read at least) contact info.
No solution yet, I am running the app on Android 10. and yes the app has the permission to access contact info
That worked for me. From Android API 23 and above you have to request permission at runtime, I updated the manifest just like you did, but the app still crashes. So i set the permission manually and it worked. There is a Asset in the store for runtime permissions requests, https://assetstore.unity.com/packages/tools/integration/android-runtime-permissions-117803 i haven't test it yet.
I still have the same issue, even when i have set the runtime permissions for the three(read sms, contacts and phone state), the app crashes on android of Api 31
Same for me