コード例 #1
0
  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);
  }
コード例 #2
0
 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;
 }