void signOut(long providerId, long accountId) {

    try {

      IImConnection conn = mApp.getConnection(mProviderId, mAccountId);
      if (conn != null) {
        conn.logout();
      } else {
        // Normally, we can always get the connection when user chose to
        // sign out. However, if the application crash unexpectedly, the
        // status will never be updated. Clear the status in this case
        // to make it recoverable from the crash.
        ContentValues values = new ContentValues(2);
        values.put(Imps.AccountStatusColumns.PRESENCE_STATUS, Imps.CommonPresenceColumns.OFFLINE);
        values.put(Imps.AccountStatusColumns.CONNECTION_STATUS, Imps.ConnectionStatus.OFFLINE);
        String where = Imps.AccountStatusColumns.ACCOUNT + "=?";
        getActivity()
            .getContentResolver()
            .update(
                Imps.AccountStatus.CONTENT_URI,
                values,
                where,
                new String[] {Long.toString(accountId)});
      }
    } catch (RemoteException ex) {
      Log.e(ImApp.LOG_TAG, "signout: caught ", ex);
    } finally {

    }
  }
  private boolean checkConnection() {
    try {
      IImConnection conn = mApp.getConnection(mProviderId, mAccountId);

      if (conn.getState() == ImConnection.DISCONNECTED) return false;

      return true;
    } catch (Exception e) {
      return false;
    }
  }