title: Firebase Firestore Data Query get calling two times?
body: <p><strong>firebase_dynamicview()</strong>  This method is getting called only once but the query is executing twice. So My Activity get creating Twice help me in this case.</p>
  
  <blockquote>
    <p><strong>Log.d("gettingcall","2222222222   ");</strong> this log is getting printed
    twice</p>
  </blockquote>
  
  <pre><code>private void firebase_dynamicview() {
      shared_menueditor.clear().commit();
      shared_menueditor.putString("success", "failure");
      shared_menueditor.apply();
      shared_menueditor.commit();
      Log.d("gettingcall","11111111111   ");
      db = FirebaseFirestore.getInstance();
      Query query = db.collection("employees");
      registration=  query.whereEqualTo("UID", sharedPref.getString("userId",null)).addSnapshotListener(new EventListener&lt;QuerySnapshot&gt;() {
          @Override
          public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) {
              if (e != null) {
              }
              if (documentSnapshots.isEmpty()){
                  closeSplash();
              }
              Log.d("gettingcall","2222222222   ");
              for (DocumentChange documentChange : documentSnapshots.getDocumentChanges()) {
                  Map&lt;String, Object&gt; forms =null;
                  if (documentChange.getDocument().getData().get("mobileMenu") != null) {
                      try 
  forms= (Map&lt;String, Object&gt;)documentChange.getDocument().getData().get("mobileMenu");
                      } catch (Exception e1) {
                          Log.e("Execeptionmenus","**   "+e1.toString());
                          e1.printStackTrace();
                      }
                  }
                  if (forms!= null) {
                      for (Map.Entry&lt;String, Object&gt; form : forms.entrySet()) {
                          String key = form.getKey();
                          if (key.contains("Attendance")) {
                              String keys = form.getKey();
                              Log.d("PrintisAttendance","****   "+forms.get(keys));
                              shared_menueditor.putString("isAttendance",""+forms.get(keys));
                          }if (key.contains("Calender")){
                              String keys = form.getKey();
                              shared_menueditor.putString("Calender",""+forms.get(keys));
                          }
                          if (key.contains("Expenses")){
                              String keys = form.getKey();
                              shared_menueditor.putString("Expenses",""+forms.get(keys));
                          }if (key.contains("Leaves")){
                              String keys = form.getKey();
                              shared_menueditor.putString("Leaves",""+forms.get(keys));
                          }if (key.contains("LogOut")){
                              String keys = form.getKey();
                              shared_menueditor.putString("LogOut",""+forms.get(keys));
                          }if (key.contains("NoticeBoard")){
                              String keys = form.getKey();
                              shared_menueditor.putString("NoticeBoard",""+forms.get(keys));
                          }if (key.contains("Tasks")){
                              String keys = form.getKey();
                              shared_menueditor.putString("Tasks",""+forms.get(keys));
                          }if(key.contains("TrackEmployee")){
                              String keys = form.getKey();
                              shared_menueditor.putString("TrackEmployee",""+forms.get(keys));
                          }
                          if (key.contains("Form")) {
                              Map&lt;Object, Object&gt; values = (Map&lt;Object, Object&gt;) form.getValue();
                              name = (String) values.get("wName");
                              String id = (String) values.get("WID");
                              if (key.contains("Form1")) {
                                  editor.putString("nav_form1", name);
                                  editor.putString("formId1",id);
                              }
                              if (key.contains("Form2")) {
                                  editor.putString("nav_form2", name);
                                  editor.putString("formId2",id);
                              }
                              if (key.contains("Form3")) {
                                  editor.putString("nav_form3", name);
                                  editor.putString("formId3",id);
                              }
                          }
                      }
                  }
              }
              shared_menueditor.apply();
              shared_menueditor.commit();
              editor.apply();
              editor.commit();
              Log.d("calllliiiiiiing******","spalsh");
              userprofile();
         }
      });
  }
  </code></pre>