Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is how I set a logout alarm for 5 minutes from now</p> <pre><code>Calendar cal1 = Calendar.getInstance(); cal1.add(Calendar.MINUTE, 5); </code></pre> <p>you can do more with the date using the methods and fields available in <strong><a href="http://developer.android.com/reference/java/util/Calendar.html" rel="nofollow">Calendar</a></strong>. For example:</p> <pre><code>Calendar cal = Calendar.getInstanc(); cal.set(Calendar.MONTH, JANUARY); </code></pre> <p>to set the month. Check that link and you can see all the different ways that you can set it. Use <code>set()</code> to set the field (month, day, etc...) and use <code>add()</code> to add to the field. This should help you get started anyway</p> <p><strong>Edit</strong></p> <p>Wherever you set your pending intent just use these variables you have set as the values</p> <pre><code> private void updatedate() { // TODO Auto-generated method stub c.set(Calendar.Month, month); // `c` is the `Calendar` instance you defined earlier. Now we are setting the month on that instance c.set(Calendar.DAY_OF_MONTH, date); } </code></pre> <p>then when you click your <code>Button</code></p> <pre><code> b2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { long alarmTime = cal.getTimeInMillis(); // convert your calendar instance with the dates set to millis Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm"); i.putExtra("alarmTime", alarmTime); //"alarmTime" will be used to get the time to set the alarm in your AlarmClock class startActivity(i); }}); </code></pre> <p>And the rest you know how to do if you are already setting a time. Hope this helps you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload