コード例 #1
0
  private IContactList getContactList(IImConnection conn) {
    if (conn == null) {
      return null;
    }

    try {
      IContactListManager contactListMgr = conn.getContactListManager();
      String listName = getSelectedListName();
      if (!TextUtils.isEmpty(listName)) {
        return contactListMgr.getContactList(listName);
      } else {
        // Use the default list
        List<IBinder> lists = contactListMgr.getContactLists();
        for (IBinder binder : lists) {
          IContactList list = IContactList.Stub.asInterface(binder);
          if (list.isDefault()) {
            return list;
          }
        }
        // No default list, use the first one as default list
        if (!lists.isEmpty()) {
          return IContactList.Stub.asInterface(lists.get(0));
        }
        return null;
      }
    } catch (RemoteException e) {
      // If the service has died, there is no list for now.
      return null;
    }
  }
コード例 #2
0
  /** @param value */
  protected void setContactNickname(String aAddress, String aNickname, IImConnection conn) {
    try {

      IContactListManager listManager = conn.getContactListManager();
      int result = listManager.setContactName(aAddress, aNickname);
      if (result != ImErrorInfo.NO_ERROR) {
        Toast.makeText(
                mContext, mContext.getString(R.string.error_prefix) + result, Toast.LENGTH_LONG)
            .show(); // TODO -LS error handling
      }
    } catch (Exception e) {
      Toast.makeText(
              mContext,
              mContext.getString(R.string.error_prefix) + e.getMessage(),
              Toast.LENGTH_LONG)
          .show(); // TODO -LS error handling
    }
    mFilterList.invalidate();
    final InputMethodManager imm =
        (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getWindowToken(), 0);
  }