title: How I can change state of widget switch from check to uncheck?
body: <p>I want to recieve data from thingspeak and change automatically state of switch from checked to unchecked or vice versa.<br>
  This is my code, but it doesn't work, just can set text but can't change state.<br>
   Please help me!</p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          button = (Button) findViewById(R.id.button);
  
          myswitch1 = (Switch) findViewById(R.id.switch1);
  
          button.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Thread t = new Thread(new Runnable() {
                      @Override
                      public void run() {
                          postdata2();
                      }
                  });
                  t.start();
                  now_da1.setText(get_da1);
                  if(get_dk1 == "1") {
                        myswitch1.setChecked(False);
                  }   
                  else if (get_dk1 =="0") {
                        myswitch1.setChecked(True);
                  }
              }
          });
  
          myswitch1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                      if (isChecked) {
                          t1 = "1";
                      } else {
                          t1 = "0";
                      }
                  }
              });
  
          public void postdata2() {
          HttpRequest mReq = new HttpRequest();
          get_t1 =    mReq.sendGet("https://thingspeak.com/channels/106453/field/1/last");
  
          get_da1 = get_t1.substring(0, 2);
          get_dk1 = get_t1.substring(3, 3);
          Log.d(myGet, get_dk1);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  }
  </code></pre>