Home>

Trying to get the name of the contact and keep yourself in the app. If the device with API below 30, all the rules runs if 30 and above, the contact name is not saved. I tried to add permissions to the manifest, but nothing helped.

<
QUERIES >
        ≪
INTENT >
            ≪
Action Android: name= "Android.accounts.accountAuthenticator" />
        ≪
/INTENT >
        ≪
! -Allows The App to Load An Icon CorreSponding to the Custom Mime Type. ->
        ≪
INTENT >
            ≪
Action Android: name= "Android.Intent.action.View" />
            ≪
Data Android: Scheme= "Content" Android: Host= "com.android.contacts"
                Android: MimeType= "VND.Android.cursor.Item /*" />
        ≪
/INTENT >
    ≪
/QUERIES >

Here is a piece of code responsible for extracting and maintaining contact

PickContactCallback= ActivityResultCallback <
URI? >
 {Contacturi: URI? ->
            Val Queryfields= Arrayof (contactscontract.contacts.display_name)
            Val Cursor= Contacturi? .let {Contacturi ->
                RequireActivity (). ContentResolver.Query (
                    Contacturi,
                    Queryfields,
                    NULL
                    NULL
                    NULL
                )
            }
            Cursor? .USE {
                if (it.count== 0) {
                    Return @ ActivityResultCallback
                }
                it.movetofirst ()
                Val Suspect= It.GetString (0)
                //Log.d(Tag, "OnactivityResult () Called -$ SUSPECT")
                crime.suspect= suspect
                CrimeDetailViewModel.savecrime (Crime)
                SuspectButton.Text= Suspect
            }
        }

In the line where there is a check if (it.Count== 0) , Cursor for some reason returns count= 0

In Contacturi, everything comes correctly?

Eugene Krivenja2021-09-18 14:42:10

It seems yes, Contacturi is not empty for sure

JayKay2021-09-17 18:07:17