Android Question Create Library Whatsapp

Discussion in 'Android Questions' started by MarcoRome, Jan 17, 2015.

  1. MarcoRome

    MarcoRome Expert Licensed User

    Hi all.
    Code:
    public final static boolean existNumber(BA ba, String phoneNumber){
            boolean exist = 
    false;
     
            
    try{
                
    ContentResolver contentResolver = ba.context.getContentResolver();
                
    Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, nullnullnullnull);
                
    if (cursor.getCount() > 0) {
                    
    while (cursor.moveToNext()) {
                        
    String contact_id = cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts._ID ));
                        int hasPhoneNumber = Integer.parseInt(
    cursor.getString(cursor.getColumnIndex( ContactsContract.Contacts.HAS_PHONE_NUMBER )));
                        
    if (hasPhoneNumber > 0) {
                            
    Cursor phoneCursor = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
                                    
    null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { contact_id }, null);
                            while (phoneCursor.moveToNext()) {
                                String phoneNumberContact = phoneCursor.getString(phoneCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                                if(phoneNumber.equals(phoneNumberContact)){
                                    exist = true;
                                    phoneCursor.close();
                                    cursor.close();
                                    return exist;
                                }
                            }
                            phoneCursor.close();
                        }
                    }
                }
                cursor.close();
            }catch(Exception e){
                exist = false;
                if(DEBUG) Log.e("Exception", e.toString());
            }
     
            return exist;
        }
    return False... also if number exit.

    Any idea ??




    Thank you all
     
    Last edited: Mar 5, 2015
  2. Beja

    Beja Expert Licensed User

    Hi MarcoRome,
    did you port it to b4a?
     
  3. MarcoRome

    MarcoRome Expert Licensed User

    In attachment you have library B4A already compiled ( whatssapp_lbrary.zip ) and start example but as already write... existPhoneNumber dont work...another function
    shareMediaWithContact, lunchmarket, etc. i have yet to try them.
     
  4. Beja

    Beja Expert Licensed User

    Thanks for the information
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice