de.unikassel.android.sdcframework.app.scheduler
Class ScheduleService

Package class diagram package ScheduleService
java.lang.Object
  extended by android.content.Context
      extended by android.content.ContextWrapper
          extended by android.app.Service
              extended by android.app.IntentService
                  extended by de.unikassel.android.sdcframework.app.scheduler.ScheduleService
All Implemented Interfaces:
ComponentCallbacks

public class ScheduleService
extends IntentService

The scheduler background process.


Nested Class Summary
private  class ScheduleService.ScheduledAlarm
          A simple structure to store the data for an alarm.
 
Field Summary
private static String ACTION
          The action this service does process from intents.
private  AlarmManager alarmManager
          The alarm manager
private  SimpleDateFormat df
          Date formatter for log messages.
private  ApplicationPreferenceManager prefManager
          The preference manager
private  PowerManager.WakeLock wakeLock
          The wake lock to keep CPU running while service is active.
 
Fields inherited from class android.app.Service
START_CONTINUATION_MASK, START_FLAG_REDELIVERY, START_FLAG_RETRY, START_NOT_STICKY, START_REDELIVER_INTENT, START_STICKY, START_STICKY_COMPATIBILITY
 
Fields inherited from class android.content.Context
ACCESSIBILITY_SERVICE, ACCOUNT_SERVICE, ACTIVITY_SERVICE, ALARM_SERVICE, AUDIO_SERVICE, BIND_AUTO_CREATE, BIND_DEBUG_UNBIND, BIND_NOT_FOREGROUND, CLIPBOARD_SERVICE, CONNECTIVITY_SERVICE, CONTEXT_IGNORE_SECURITY, CONTEXT_INCLUDE_CODE, CONTEXT_RESTRICTED, DEVICE_POLICY_SERVICE, DROPBOX_SERVICE, INPUT_METHOD_SERVICE, KEYGUARD_SERVICE, LAYOUT_INFLATER_SERVICE, LOCATION_SERVICE, MODE_APPEND, MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITEABLE, NOTIFICATION_SERVICE, POWER_SERVICE, SEARCH_SERVICE, SENSOR_SERVICE, TELEPHONY_SERVICE, UI_MODE_SERVICE, VIBRATOR_SERVICE, WALLPAPER_SERVICE, WIFI_SERVICE, WINDOW_SERVICE
 
Constructor Summary
ScheduleService()
          Constructor
 
Method Summary
private  void acquireWakeLock()
          Does acquire the wake lock
static Intent createIntent(Context applicationContext)
          Does create an intent to start the schedule service
private static PendingIntent createPendingIntent(Intent intent, Context context)
          Does create a pending intent to start this service.
protected  void execute(WeekdaySchedulerAction action)
          Does execute a scheduled action
private  WeekdayScheduleEntry getEntryFromIntent(Intent intent, WeeklySchedule schedule)
          Method to get a scheduled valid entry from an intent (valid according to the given schedule ).
private  ScheduleService.ScheduledAlarm getNextAlarm(WeeklySchedule schedule, Calendar now, WeekdayScheduleEntry lastScheduledEntry)
          Method to calculate the next alarm based on time and a given schedule.
private  PowerManager.WakeLock getWakeLock()
          Getter for the wake lock
 void onCreate()
           
 void onDestroy()
           
protected  void onHandleIntent(Intent intent)
           
private  void releaseWakeLock()
          Does release the wake lock
private  void setAlarm(ScheduleService.ScheduledAlarm alarm)
          Method to set a new alarm for next event.
private  void setWakeLock(PowerManager.WakeLock wakeLock)
          Setter for the wake lock
 
Methods inherited from class android.app.IntentService
onBind, onStart, onStartCommand, setIntentRedelivery
 
Methods inherited from class android.app.Service
dump, finalize, getApplication, onConfigurationChanged, onLowMemory, onRebind, onUnbind, setForeground, startForeground, stopForeground, stopSelf, stopSelf, stopSelfResult
 
Methods inherited from class android.content.ContextWrapper
attachBaseContext, bindService, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingPermission, checkCallingUriPermission, checkPermission, checkUriPermission, checkUriPermission, clearWallpaper, createPackageContext, databaseList, deleteDatabase, deleteFile, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAssets, getBaseContext, getCacheDir, getClassLoader, getContentResolver, getDatabasePath, getDir, getExternalCacheDir, getExternalFilesDir, getFilesDir, getFileStreamPath, getMainLooper, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getResources, getSharedPreferences, getSystemService, getTheme, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isRestricted, openFileInput, openFileOutput, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, removeStickyBroadcast, revokeUriPermission, sendBroadcast, sendBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendStickyBroadcast, sendStickyOrderedBroadcast, setTheme, setWallpaper, setWallpaper, startActivity, startInstrumentation, startIntentSender, startService, stopService, unbindService, unregisterReceiver
 
Methods inherited from class android.content.Context
getString, getString, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION

private static final String ACTION
The action this service does process from intents.

See Also:
Constant Field Values

prefManager

private ApplicationPreferenceManager prefManager
The preference manager


alarmManager

private AlarmManager alarmManager
The alarm manager


df

private final SimpleDateFormat df
Date formatter for log messages.


wakeLock

private PowerManager.WakeLock wakeLock
The wake lock to keep CPU running while service is active.

Constructor Detail

ScheduleService

public ScheduleService()
Constructor

Method Detail

onCreate

public void onCreate()
Overrides:
onCreate in class IntentService

onDestroy

public void onDestroy()
Overrides:
onDestroy in class IntentService

onHandleIntent

protected final void onHandleIntent(Intent intent)
Specified by:
onHandleIntent in class IntentService

setAlarm

private final void setAlarm(ScheduleService.ScheduledAlarm alarm)
Method to set a new alarm for next event.

Parameters:
alarm - the alarm to create

createPendingIntent

private static final PendingIntent createPendingIntent(Intent intent,
                                                       Context context)
Does create a pending intent to start this service.

Parameters:
intent - the intent to wrap
context - the context
Returns:
a pending intent to start this service

createIntent

public static final Intent createIntent(Context applicationContext)
Does create an intent to start the schedule service

Parameters:
applicationContext - the context
Returns:
an intent to start the schedule service

getNextAlarm

private final ScheduleService.ScheduledAlarm getNextAlarm(WeeklySchedule schedule,
                                                          Calendar now,
                                                          WeekdayScheduleEntry lastScheduledEntry)
Method to calculate the next alarm based on time and a given schedule.

Parameters:
schedule - the current schedule
now - the current time stamp
lastScheduledEntry - the last scheduled entry if known
Returns:
the next scheduled alarm

execute

protected final void execute(WeekdaySchedulerAction action)
Does execute a scheduled action

Parameters:
action - the action to execute

getEntryFromIntent

private final WeekdayScheduleEntry getEntryFromIntent(Intent intent,
                                                      WeeklySchedule schedule)
Method to get a scheduled valid entry from an intent (valid according to the given schedule ).

Parameters:
intent - the intent to create scheduled entry from
schedule - the schedule to validate an existing entry for
Returns:
the scheduled valid entry from this intent or null

setWakeLock

private final void setWakeLock(PowerManager.WakeLock wakeLock)
Setter for the wake lock

Parameters:
wakeLock - the wake lock to set

getWakeLock

private final PowerManager.WakeLock getWakeLock()
Getter for the wake lock

Returns:
the wake lock

releaseWakeLock

private final void releaseWakeLock()
Does release the wake lock


acquireWakeLock

private final void acquireWakeLock()
Does acquire the wake lock