Unity-Contacts-List icon indicating copy to clipboard operation
Unity-Contacts-List copied to clipboard

App just crashes

Open Akash437 opened this issue 4 years ago • 5 comments

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

Akash437 avatar Oct 24 '20 13:10 Akash437

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.

CarlosNoVir avatar Nov 06 '20 10:11 CarlosNoVir

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

Akash437 avatar Nov 09 '20 03:11 Akash437

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.

CarlosNoVir avatar Nov 09 '20 11:11 CarlosNoVir

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

josValentin avatar Jan 20 '21 22:01 josValentin

Same for me

anatolii-genies avatar Jun 21 '21 19:06 anatolii-genies