title: Get chat dialogs after login to chat Quickblox
body: <p>I am trying to invoke a method to get chat dialogs after logging in succesfully on QBChatService but when I do it, it triggers onError method, the method that gets dialogs works fine if I invoke it separately. Here is my code:</p>
  
  <pre><code>    public class ChatService {
  
        public static final int AUTO_PRESENCE_INTERVAL_IN_SECONDS = 30;
        private static ChatService instance;
        private QBChatService qbChatService;
        private ArrayList&lt;QBUser&gt; opponentsUsers = new ArrayList&lt;QBUser&gt;();
        private Map&lt;List&lt;Integer&gt;, QBDialog&gt; chatDialogsHashMap = new HashMap&lt;List&lt;Integer&gt;, QBDialog&gt;();
        private ArrayList&lt;QBDialog&gt; chatDialogsArrayList = new ArrayList&lt;QBDialog&gt;();
  
        private ConnectionListener chatConnectionListener = new ConnectionListener() {
          @Override
          public void connected(XMPPConnection connection) {
              Log.w("CHAT SERVICE", "connected");
          }
  
          @Override
          public void authenticated(XMPPConnection connection) {
              Log.w("CHAT SERVICE", "authenticated");
          }
  
          @Override
          public void connectionClosed() {
              Log.w("CHAT SERVICE", "connectionClosed");
          }
  
          @Override
          public void connectionClosedOnError(final Exception e) {
              Log.w("CHAT SERVICE", "connectionClosedOnError: " + e.getLocalizedMessage());
          }
  
          @Override
          public void reconnectingIn(final int seconds) {
              if(seconds % 5 == 0) {
                  Log.w("CHAT SERVICE", "reconnectingIn: " + seconds);
              }
          }
  
          @Override
          public void reconnectionSuccessful() {
              Log.w("CHAT SERVICE", "reconnectionSuccessful");
          }
  
          @Override
          public void reconnectionFailed(final Exception error) {
              Log.w("CHAT SERVICE", "reconnectionFailed: " + error.getLocalizedMessage());
          }
      };
  
  
  
      public ChatService(){
          this.qbChatService = QBChatService.getInstance();
          this.qbChatService.addConnectionListener(this.chatConnectionListener);
      }
  
      public static synchronized ChatService getInstance(){
          if(instance == null){
             instance = new ChatService();
          }
          return instance;
      }
  
      public static boolean initializedIfNeeded(Context context){
          if(!QBChatService.isInitialized()){
              QBChatService.init(context);
              QBChatService.setDebugEnabled(true);
              Log.w("INITIALIZED QBCHAT", "SUCCESS");
              return true;
          }
          return false;
      }
  
      public void loginToChat(){
          QBAuth.getSession(new QBEntityCallbackImpl&lt;QBSession&gt;() {
              @Override
              public void onSuccess(QBSession qbSession, Bundle bundle) {
                  Log.w("GET SESSION", "SUCCESS");
                  QBUser currentSessionUser = new QBUser();
                  currentSessionUser.setId(qbSession.getUserId());
                  currentSessionUser.setLogin(MenuActivity.sharedPreferences.getString("USERNAME", ""));
                  currentSessionUser.setPassword(MenuActivity.sharedPreferences.getString("PASSWORD", ""));
                  ChatService.this.qbChatService.login(currentSessionUser, new QBEntityCallbackImpl() {
                      @Override
                      public void onSuccess() {
                          Log.w("LOGIN TO CHAT", "SUCCESS");
                          ChatService.this.storeChatDialogs();
                          try {
                              ChatService.this.qbChatService.startAutoSendPresence(AUTO_PRESENCE_INTERVAL_IN_SECONDS);
                          } catch (SmackException.NotLoggedInException e) {
                              e.printStackTrace();
                          }
  
                      }
  
                      @Override
                      public void onError(List list) {
                          Log.w("LOGIN TO CHAT", "ERROR");
                      }
                  });
              }
  
  
              @Override
              public void onError(List&lt;String&gt; list) {
                  Log.w("GET SESSION", "ERROR");
              }
          });
  
  
      }
  
      public void createPrivateDialog(final Activity activity, QBDialog dialogToCreate){
          this.qbChatService.getGroupChatManager().createDialog(dialogToCreate, new QBEntityCallbackImpl&lt;QBDialog&gt;() {
              @Override
              public void onSuccess(QBDialog qbDialog, Bundle bundle) {
                  Log.w("CREATE DIALOG", "SUCCESS");
                  ((MenuActivity) activity).changeDialog(qbDialog);
              }
  
              @Override
              public void onError(List&lt;String&gt; list) {
                  Log.w("CREATE DIALOG", "EXITO");
              }
          });
      }
  
      public void storeChatDialogs(){
          QBChatService.getChatDialogs(QBDialogType.PRIVATE, new QBRequestGetBuilder(), new QBEntityCallbackImpl&lt;ArrayList&lt;QBDialog&gt;&gt;() {
              @Override
              public void onSuccess(ArrayList&lt;QBDialog&gt; qbDialogs, Bundle bundle) {
                  Log.w("STORE CHAT DIALOGS", "SUCCESS");
                  ArrayList&lt;QBDialog&gt; dialogsFromCurrentUser = new ArrayList&lt;QBDialog&gt;();
                  for (QBDialog dialog : qbDialogs) {
                      ArrayList&lt;Integer&gt; occupantsIDs = dialog.getOccupants();
                      for (Integer ID : occupantsIDs) {
                          if (ChatService.getInstance().getCurrentChatUser().getId() == ID.intValue()) {
                              dialogsFromCurrentUser.add(dialog);
                          }
                      }
                  }
                  ChatService.this.storeOpponentsUsersOfPrivateDialogs(dialogsFromCurrentUser);
                  ChatService.this.setChatDialogsHashMap(dialogsFromCurrentUser);
                  ChatService.this.setChatDialogsArrayList(dialogsFromCurrentUser);
              }
  
              @Override
              public void onError(List&lt;String&gt; list) {
                  Log.w("STORE CHAT DIALOGS", "ERROR");
              }
          });
      }
  
      public QBUser getCurrentChatUser(){
          return this.qbChatService.getUser();
      }
  
      public Integer getOpponentIDForPrivateDialog(QBDialog dialog){
          Integer opponentID = 0;
          for(Integer userID : dialog.getOccupants()){
              if(!userID.equals(getCurrentChatUser().getId())){
                  opponentID = userID;
              }
          }
          return opponentID;
      }
  
      public void storeOpponentsUsersOfPrivateDialogs(ArrayList&lt;QBDialog&gt; privateDialogs){
          this.opponentsUsers.clear();
          QBUsers.getUsersByIDs(this.getOpponentsIDsOfPrivateDialogs(privateDialogs), new QBPagedRequestBuilder(), new QBEntityCallbackImpl&lt;ArrayList&lt;QBUser&gt;&gt;() {
              @Override
              public void onSuccess(ArrayList&lt;QBUser&gt; qbUsers, Bundle bundle) {
                  Log.w("GET USERS BY IDS", "SUCCESS");
                  ChatService.this.opponentsUsers = qbUsers;
              }
  
              @Override
              public void onError(List&lt;String&gt; list) {
                  Log.w("GET USERS BY IDS", "ERROR");
              }
          });
      }
  
      public ArrayList&lt;Integer&gt; getOpponentsIDsOfPrivateDialogs(ArrayList&lt;QBDialog&gt; privateDialogs){
          ArrayList&lt;Integer&gt; opponentsIDs = new ArrayList&lt;Integer&gt;();
          for(QBDialog dialog : privateDialogs){
              ArrayList&lt;Integer&gt; occupantsIDs = dialog.getOccupants();
              for(Integer ID : occupantsIDs){
                  if(this.getCurrentChatUser().getId() != ID.intValue()){
                      opponentsIDs.add(ID);
                  }
              }
          }
          return opponentsIDs;
      }
  
      public QBDialog getDialog(List&lt;Integer&gt; occupantsIDs){
          return this.chatDialogsHashMap.get(occupantsIDs);
      }
  
      public ArrayList&lt;QBDialog&gt; getChatDialogsArrayList(){
          return this.chatDialogsArrayList;
      }
  
      public void setChatDialogsArrayList(List&lt;QBDialog&gt; dialogs){
          this.chatDialogsArrayList.clear();
          for(QBDialog dialog : dialogs){
              this.chatDialogsArrayList.add(dialog);
          }
      }
  
      public Map&lt;List&lt;Integer&gt;, QBDialog&gt; getChatDialogsHashMap(){
          return this.chatDialogsHashMap;
      }
  
      public void setChatDialogsHashMap(List&lt;QBDialog&gt; dialogs){
          this.chatDialogsHashMap.clear();
          for(QBDialog dialog : dialogs){
              this.chatDialogsHashMap.put(dialog.getOccupants(), dialog);
          }
      }
  
      public void setAndRefreshAdapter(Context context, ListView dialogsList){
          ArrayList&lt;String&gt; opponentsNames = new ArrayList&lt;String&gt;();
          for(QBUser opponentUser : this.opponentsUsers){
              opponentsNames.add(opponentUser.getLogin());
              Log.w("SET ADAPTER", opponentUser.getLogin());
          }
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(context, R.layout.option_player, R.id.textView_PlayersFragment_textOption, opponentsNames);
          dialogsList.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>It doesn't show any error, but I put logcat here:</p>
  
  <pre><code>07-28 17:06:59.217  28003-28003/com.example.jozumaster.myapplication W/INITIALIZED QBCHAT﹕ SUCCESS
  07-28 17:06:59.630  28003-28051/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x6186c9d8 cert_verify_callback x509_store_ctx=0x625de940 arg=0x0
  07-28 17:06:59.630  28003-28051/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x6186c9d8 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
  07-28 17:07:00.027  28003-28003/com.example.jozumaster.myapplication W/CREATE SESSION﹕ SUCCESS
  07-28 17:07:08.832  28003-28522/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x61d0bdb0 cert_verify_callback x509_store_ctx=0x64cf6940 arg=0x0
  07-28 17:07:08.832  28003-28522/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x61d0bdb0 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
  07-28 17:07:08.970  28003-28003/com.example.jozumaster.myapplication W/dalvikvm﹕ VFY: unable to resolve virtual method 457: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
  07-28 17:07:08.971  28003-28003/com.example.jozumaster.myapplication W/dalvikvm﹕ VFY: unable to resolve virtual method 479: Landroid/content/res/TypedArray;.getType (I)I
  07-28 17:07:09.415  28003-28529/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x615d1a88 cert_verify_callback x509_store_ctx=0x64ef2940 arg=0x0
  07-28 17:07:09.415  28003-28529/com.example.jozumaster.myapplication E/NativeCrypto﹕ ssl=0x615d1a88 cert_verify_callback calling verifyCertificateChain authMethod=DHE_RSA
  07-28 17:07:09.506  28003-28003/com.example.jozumaster.myapplication W/SIGN IN﹕ SUCCESS
  07-28 17:07:09.852  28003-28003/com.example.jozumaster.myapplication W/GET SESSION﹕ SUCCESS
  07-28 17:07:10.314  28003-28538/com.example.jozumaster.myapplication W/CHAT SERVICE﹕ connected
  07-28 17:07:11.008  28003-28538/com.example.jozumaster.myapplication W/CHAT SERVICE﹕ authenticated
  07-28 17:07:11.011  28003-28538/com.example.jozumaster.myapplication W/LOGIN TO CHAT﹕ SUCCESS
  07-28 17:07:11.017  28003-28538/com.example.jozumaster.myapplication W/LOGIN TO CHAT﹕ ERROR
  </code></pre>