void updatePresenceContent(Contact[] contacts) {
    ArrayList<String> usernames = new ArrayList<String>();
    ArrayList<String> statusArray = new ArrayList<String>();
    ArrayList<String> customStatusArray = new ArrayList<String>();
    ArrayList<String> clientTypeArray = new ArrayList<String>();

    for (Contact c : contacts) {
      String username = c.getAddress().getFullName();
      Presence p = c.getPresence();
      int status = convertPresenceStatus(p);
      String customStatus = p.getStatusText();
      int clientType = translateClientType(p);

      usernames.add(username);
      statusArray.add(String.valueOf(status));
      customStatusArray.add(customStatus);
      clientTypeArray.add(String.valueOf(clientType));
    }

    ContentValues values = new ContentValues();
    values.put(Imps.Contacts.ACCOUNT, mAccountId);
    putStringArrayList(values, Imps.Contacts.USERNAME, usernames);
    putStringArrayList(values, Imps.Presence.PRESENCE_STATUS, statusArray);
    putStringArrayList(values, Imps.Presence.PRESENCE_CUSTOM_STATUS, customStatusArray);
    putStringArrayList(values, Imps.Presence.CONTENT_TYPE, clientTypeArray);

    mResolver.update(Imps.Presence.BULK_CONTENT_URI, values, null, null);
  }
 private ContentValues getPresenceValues(long contactId, Presence p) {
   ContentValues values = new ContentValues(3);
   values.put(Imps.Presence.CONTACT_ID, contactId);
   values.put(Imps.Contacts.PRESENCE_STATUS, convertPresenceStatus(p));
   values.put(Imps.Contacts.PRESENCE_CUSTOM_STATUS, p.getStatusText());
   values.put(Imps.Presence.CLIENT_TYPE, translateClientType(p));
   return values;
 }
 private int translateClientType(Presence presence) {
   int clientType = presence.getClientType();
   switch (clientType) {
     case Presence.CLIENT_TYPE_MOBILE:
       return Imps.Presence.CLIENT_TYPE_MOBILE;
     default:
       return Imps.Presence.CLIENT_TYPE_DEFAULT;
   }
 }
  /**
   * Converts the presence status to the value defined for ImProvider.
   *
   * @param presence The presence from the IM engine.
   * @return The status value defined in for ImProvider.
   */
  public static int convertPresenceStatus(Presence presence) {
    switch (presence.getStatus()) {
      case Presence.AVAILABLE:
        return Imps.Presence.AVAILABLE;

      case Presence.IDLE:
        return Imps.Presence.IDLE;

      case Presence.AWAY:
        return Imps.Presence.AWAY;

      case Presence.DO_NOT_DISTURB:
        return Imps.Presence.DO_NOT_DISTURB;

      case Presence.OFFLINE:
        return Imps.Presence.OFFLINE;
    }

    // impossible...
    Log.e(TAG, "Illegal presence status value " + presence.getStatus());
    return Imps.Presence.AVAILABLE;
  }