title: How can I return a boolean value from this toggle button listener?
body: <p>I need to return a boolean value from the toggle button listener to switch the system on and off. With the method being void, it yells at me if I try to return a boolean. If boolean is not possible, returning a string would suffice. I am new to android so the answer is probably simple but I am lost. Thanks in advance!</p>
  
  <p>The imports    </p>
  
  <pre><code>import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import com.google.firebase.database.DataSnapshot;
  import com.google.firebase.database.DatabaseError;
  import com.google.firebase.database.DatabaseReference;
  import com.google.firebase.database.FirebaseDatabase;
  import com.google.firebase.database.ValueEventListener;
  import com.google.android.gms.tasks.OnCompleteListener;
  import android.widget.CompoundButton;
  import android.widget.CompoundButton.OnCheckedChangeListener;
  import android.widget.ToggleButton;
  
  public class SettingsActivity extends AppCompatActivity {
  
  
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_settings);
  
  
      //creating database instance
      FirebaseDatabase database = FirebaseDatabase.getInstance();
      final DatabaseReference rootRef = database.getReference("user/key/plants/reaper");
      //FirebaseDatabase data = new FirebaseDatabase("test-5487a/user/key/plants/reaper");
      //mRef = new FirebaseDatabase("https://test-5487a.firebaseio.com/");
  </code></pre>
  
  <p>The toggle button and listener</p>
  
  <pre><code>    ToggleButton toggle = (ToggleButton) findViewById(R.id.PowerButton);
      toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
              if (isChecked) {
                  // The toggle is enabled
              } else {
                  // The toggle is disabled
              }
          }
      });
  </code></pre>