Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You could store a single <code>byte</code> to represent your week and pull values out of it using a bitwise <code>&amp;</code> operation. Bit 1 could represent Monday, Bit 2 Tuesday, etc. You can use this to represent all combinations of days, e.g:</p> <pre><code>01100000 - Saturday/Sunday (Weekend) 01110001 - Friday/Saturday/Sunday/Monday (Long weekend) </code></pre> <p>When reading the value you would use something like:</p> <pre><code>byte val = 0x71; //01110001 boolean mondayActive = (val &amp; 0x1) == 1; boolean fridayActive = (val &gt;&gt; 4&amp; 0x1) == 1; </code></pre> <p><strong>EDIT comment</strong><br/> This assumes that you are already familiar with the <a href="http://developer.android.com/reference/android/app/AlarmManager.html" rel="nofollow">AlarmManager</a> and were looking for a mechanism to track your alarms as you cannot use a single alarm to schedule events in the manner the OP described. If you need to mimic cron in a single task, possibly take a look at something like the <a href="http://hub.buzzbox.com/android-sdk/scheduler" rel="nofollow">BuzzBox</a> SDK.</p> <p><strong>EDIT write sample</strong></p> <pre><code>public static final int MONDAY = 0x01; //00000001 public static final int TUESDAY = 0x02; //00000010 public static final int WEDNESDAY = 0x04; //00000100 public static final int THURSDAY = 0x08; //00001000 public static final int FRIDAY = 0x10; //00010000 public static final int SATURDAY = 0x20; //00100000 public static final int SUNDAY = 0x40; //01000000 //example values to write int weekend = SATURDAY | SUNDAY; //01100000 int longWeekend = FRIDAY | SATURDAY | SUNDAY | MONDAY; //01110001 //and as per flightplanner's comment, to read boolean mondayActive = (weekend &amp; MONDAY) == MONDAY; //false mondayActive = (longWeekend &amp; MONDAY) == MONDAY; //true </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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