title: How Call the getDataFromApi() function using Thread
body: <p>I'm taking the google calendar API data for my mobile application. i want to check the time to time the changes of the calendar. For that i know, i have to used a thread.</p>
  
  <pre><code>if (isChecked) {
                      Runnable runnable = new Runnable() {
                          public void run() {
                              long endTime = System.currentTimeMillis() + 1000;
  
                              while (System.currentTimeMillis() &lt; endTime) {
                                  synchronized (this) {
                                      try {
                                          getResultsFromApi();
                                      } catch (Exception e) {}
                                  }
                              }
                          }
                      };
                      Thread mythread = new Thread(runnable);
                      mythread.start();
                      Toast.makeText(AlertActivity.this, "Calendar Settings Enabled",
                              Toast.LENGTH_SHORT).show();
                  } else {
                      // The toggle is disabled
                      for(int i=0;i&lt;=broadcastCodeCal;i++)
                          cancel_Alarm(i);
                      Toast.makeText(AlertActivity.this, "Calendar Settings Disabled",
                              Toast.LENGTH_SHORT).show();
                  }
  </code></pre>
  
  <p>I want to know how to check the calendar details changes time time to through the mobile application... please guide me...</p>