Android to calculate Sleep cycles of a person
<p>I'd like to create an android application which calculates sleep cycles for a person. For example, I'd like to get up at 5:00 AM, so I need to get to bed at 9:15 PM. I still don't know algorithms for this, but I found a Java program about calculating sleep cyles. I'd like to try this in Android wherein a user should choose from spinners the HR:MM:TIME and the format is 12 HR. </p>

<p>Here's what I found: </p>

<pre><code>/** Date param for extra */
public static final String DATE_PARAM = "date";
/** Choice param for extra */
public static final String CHOICE_PARAM = "choice";

 /**
   * Get times to wake. We add 14 minutes to fall asleep, and calculate the
   * sleep cycles.
   * 
   * @return list of times when to get up
   */
  public static Set&lt;Date&gt; getWakingTimes() {
    return getWakingTime(new Date());
  }

  /**
   * Get times to wake. We add 14 minutes to fall asleep, and calculate the
   * sleep cycles.
   * 
   * @param sleepTime
   *            bed time
   * 
   * @return list of times when to get up
   */
  public static Set&lt;Date&gt; getWakingTime(Date sleepTime) {
    Calendar fallAsleep = Calendar.getInstance();
    fallAsleep.setTime(sleepTime);
    fallAsleep.add(Calendar.MINUTE, 14);
    Set&lt;Date&gt; result = new TreeSet&lt;Date&gt;();
    for (int i = 1; i &lt;= 6; i++) {
      fallAsleep.add(Calendar.MINUTE, 90);
      result.add(fallAsleep.getTime());
    }
    return result;
  }

  /**
   * Get sleeping times corresponding to a local time
   * 
   * @param wakingTime
   *            time to wake up !
   * @return list of times one should go to bed to
   */
  public static Set&lt;Date&gt; getSleepingTimes(Date wakingTime) {

    Set&lt;Date&gt; result = new TreeSet&lt;Date&gt;();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(wakingTime);
    calendar.add(Calendar.MINUTE, -14);
    calendar.add(Calendar.MINUTE, -(2 * 90));
    for (int i = 3; i &lt;= 6; i++) {
      calendar.add(Calendar.MINUTE, -90);
      result.add(calendar.getTime());
    }
    return result;

  } // end of getSleepingTimes method
</code></pre>

<p>What so far I have as my activity here is this:
<img src="http://i.stack.imgur.com/Fsj29.png" alt="enter image description here"></p>

<p>I'm still new to Android programming and needing some help from anyone who is expert. Thanks for all who will help. I want to know how it is done in Android.</p>
