I am trying to get contacts having WhatsApp using below code
final String[] PROJECTION = {
ContactsContract.Data.CONTACT_ID,
ContactsContract.Data.DISPLAY_NAME,
ContactsContract.Data.DATA1,
ContactsContract.RawContacts.ACCOUNT_TYPE,
};
final String selection = "(" +
ContactsContract.RawContacts.ACCOUNT_TYPE + " = ? OR " +
ContactsContract.RawContacts.ACCOUNT_TYPE + " = ? ) AND " +
ContactsContract.Data.MIMETYPE + " = ? ";
final String[] selectionArgs = {"com.whatsapp", "com.whatsapp.w4b", ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE};
ContentResolver cr = requireActivity().getContentResolver();
Cursor cursor_Android_Contacts = cr.query(ContactsContract.Data.CONTENT_URI, PROJECTION, selection, selectionArgs, DISPLAY_NAME);
Its working fine in all android version and devices except OPPO devices having android Version 10, in this devices cursor always returns count 0 or 1 , 2 in some cases.
I need help to understand the root cause of this issue, why this is not working in some devices and works in other devices