Sunday, 30 September 2018

Retrieving owner information on Samsung Galaxy S9

I am trying to programmatically obtain the user's profile information in an Android application. This works fine on a Pixel phone but doesn't return any results on a Samsung phone. For example:

String contactId = null;

// getting contacts ID
Cursor cursorID = getContentResolver().query(ContactsContract.Profile.CONTENT_URI,
            new String[]{ContactsContract.Contacts._ID},
            null, null, null);

if (cursorID.moveToFirst()) {
    contactId = cursorID.getString(cursorID.getColumnIndex(ContactsContract.Contacts._ID));
}

On the Pixel this returns the contact id of the phone's owner. On the Galaxy the cursor is empty. I'm assuming this is because Samsung is using some proprietary version of contacts that is not exposed through the standard Android API. Can anyone confirm? Is there an alternative for Samsung devices?



from Retrieving owner information on Samsung Galaxy S9

No comments:

Post a Comment