Search code examples
androidandroid-contactsgraphical-logo

mark a contact with app logo


I basically have a list of contacts in my app, I want to mark certain contacts on the list with the logo of my app if they are registered on my database. I have sorted out the server integration, but not sure how to add my logo to the contact list.

Examples of apps that have done something similar: Viber and Rebtel.

EDIT: the cycle of it is as such:

  1. I query my app for all the usernames
  2. I post these to the server
  3. the server returns a string like: "server says:1=johndoe" as the common username
  4. how would I take that string and and mark "johndoe" as a registered user?

My getView is:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    View view = convertView;

        if (view == null) {
            view = mInflater.inflate(R.layout.screen_contact_item, null);}

    final Contact contact = (Contact)getItem(position);

        if(contact != null){
            final TextView DisplayName = (TextView)
            view.findViewById(R.id.screen_contacts_item_textView);
    DisplayName.setText(contact.getDisplayName());}

Solution

  • I solved it by:

    for (Contact contact : list) {
            List<PhoneNumber> ListAllNumbers = contact.getPhoneNumbers();
    
            for (PhoneNumber aNum : ListAllNumbers) {
    
                for (String anAppNum : compareServer) {
                    if (aNum.getNumber().contentEquals(anAppNum)) {
                        contact.setAppContact(true);
                        Log.i(TAG, contact.getDisplayName() + " is registered");
                    }
    

    Then in the getView, I added an if statement to set a drawable to the contact if it is an AppContact, or set drawable to hidden if they are not.