How to check whatsapp numbers java android

Viewed 156

I have a Java code that deals with the numbers registered inside the mobile , so that it checks whether these numbers work on WhatsApp or not I want to make the code deal with numbers that are not registered on the mobile phone numbers that are called from within array Note that I use Java with Android Studio

private void getAllWhatsappNumbers(){
        ArrayList<String> whatsAppContact = new ArrayList();
         Cursor c = getContentResolver().query(ContactsContract.RawContacts.CONTENT_URI, new String[] { ContactsContract.RawContacts.CONTACT_ID, ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY }, ContactsContract.RawContacts.ACCOUNT_TYPE + "= ?", new String[] { "com.whatsapp" }, null);
         ArrayList<String> myWhatsappContacts = new ArrayList<String>();
         int name = c.getColumnIndex(ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY);
         while (c.moveToNext()){
            whatsAppContact.add(c.getString(name));
        }
        for(int i=0; i<whatsAppContact.size()-1; i++) {
            Log.i("print: "," "+whatsAppContact.get(i));
       }
    }
0 Answers
Related