title: Background sticky concurrent mark sweep GC freed while using firebase database
body: <p>I'm making an app for IoT devices. My app has different activities for fetching data from different sensors.
  Every activity receives data on a button click. Whenever I press the button I get the following error.</p>
  
  <pre><code> confirm2.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  // Get your custom_toast.xml layout
                  LayoutInflater inflater = getLayoutInflater();
  
                  final View layout = inflater.inflate(R.layout.custom_toast,
                          (ViewGroup) findViewById(R.id.custom_toast_layout_id));
  
                  //Initializing the text views
                  EditText editText =  findViewById(R.id.link2);
                  final String link2 = editText.getText().toString();
  
                  EditText editText1 =  findViewById(R.id.idvalue);
                  final String StringValue = editText1.getText().toString();
  
  
                  //Adding functionality to the text views
                  fire2 = new Firebase("https://iotsense.firebaseio.com/");
                  Firebase fireChild = fire2.child(link2+"/S1");
                  fireChild.setValue("4");
  
                  // Read from the database
                  myRef = FirebaseDatabase.getInstance().getReference();
                  myRef.addValueEventListener(new ValueEventListener() {
                      @Override
                      public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                          // This method is called once with the initial value and again
                          // whenever data at this location is updated.
  
                          if(StringValue.length()&gt;0 &amp;&amp; link2.length()&gt;0) {
  
                              try {
                              status = dataSnapshot.child(link2 + "/Analog").getValue().toString();}
                              catch (NullPointerException ignored){}
  
                              if(status==null){
                                  TextView text4 = layout.findViewById(R.id.text4);
                                  text4.setText(" Error: Wrong ID. ");
                                  // Toast...
                                  Toast toast = new Toast(getApplicationContext());
                                  toast.setGravity(Gravity.CENTER_VERTICAL, 0, 540);
                                  toast.setDuration(Toast.LENGTH_LONG);
                                  toast.setView(layout);
                                  toast.show();
                                  return;
                              }
                              else {
                                  analogvalue = Integer.parseInt(status);
  
                                  pin.setText(status);
  
                                  final int value = Integer.parseInt(StringValue);
                                  if (analogvalue &gt; value) {
                                      Firebase fireChild = fire2.child(link2 + "/Pin1");
                                      fireChild.setValue(spinner1.getSelectedItem().toString());
                                      Firebase fireChild1 = fire2.child(link2 + "/Pin2");
                                      fireChild1.setValue(spinner2.getSelectedItem().toString());
  
                                  }
                                  if (analogvalue &lt;= value) {
                                      if(spinner1.getSelectedItem().toString().equals("HIGH")){Firebase fireChild = fire2.child(link2 + "/Pin1"); fireChild.setValue("LOW");}
                                      if(spinner1.getSelectedItem().toString().equals("LOW")) {Firebase fireChild = fire2.child(link2 + "/Pin1"); fireChild.setValue("HIGH");}
                                      if(spinner2.getSelectedItem().toString().equals("HIGH")){Firebase fireChild = fire2.child(link2 + "/Pin2"); fireChild.setValue("LOW");}
                                      if(spinner2.getSelectedItem().toString().equals("LOW")) {Firebase fireChild = fire2.child(link2 + "/Pin2"); fireChild.setValue("HIGH");}
                                  }
                              }
                          }
                      }
  </code></pre>
  
  <pre><code>I/art: Background sticky concurrent mark sweep GC freed 132932(5MB) AllocSpace objects, 21(744KB) LOS objects, 13% free, 35MB/40MB, paused 1.556ms total 109.059ms
  I/art: Background sticky concurrent mark sweep GC freed 94569(3MB) AllocSpace objects, 0(0B) LOS objects, 5% free, 38MB/40MB, paused 8.078ms total 68.990ms
  I/art: Background sticky concurrent mark sweep GC freed 101736(3MB) AllocSpace objects, 0(0B) LOS objects, 3% free, 39MB/40MB, paused 5.349ms total 81.087ms
  I/art: Background sticky concurrent mark sweep GC freed 48181(1662KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 40MB/40MB, paused 5.361ms total 56.784ms
  </code></pre>