Class PollingScheduler


  • public class PollingScheduler
    extends android.content.BroadcastReceiver
    Schedules polling for updates from the Tapkey Trust Service. Most notably instances of this class poll for updated access keys on a periodic base. The app's Application instance must implement the TapkeyAppContext interface in order for this class to function. This class is used by registering it via its register(Context, int, int) method.
     PollingScheduler.register(this, uniqueJobId, PollingScheduler.DEFAULT_INTERVAL);
     
    • Nested Class Summary

      • Nested classes/interfaces inherited from class android.content.BroadcastReceiver

        android.content.BroadcastReceiver.PendingResult
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_INTERVAL
      The default polling interval of eight hours.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void onReceive​(android.content.Context context, android.content.Intent intent)  
      static Closeable register​(android.content.Context context, int jobId, int intervalMs)
      Registers polling for Tapkey notifications.
      • Methods inherited from class android.content.BroadcastReceiver

        abortBroadcast, clearAbortBroadcast, getAbortBroadcast, getDebugUnregister, getResultCode, getResultData, getResultExtras, goAsync, isInitialStickyBroadcast, isOrderedBroadcast, peekService, setDebugUnregister, setOrderedHint, setResult, setResultCode, setResultData, setResultExtras
    • Field Detail

      • DEFAULT_INTERVAL

        public static final int DEFAULT_INTERVAL
        The default polling interval of eight hours.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PollingScheduler

        public PollingScheduler()
    • Method Detail

      • onReceive

        public void onReceive​(android.content.Context context,
                              android.content.Intent intent)
        Specified by:
        onReceive in class android.content.BroadcastReceiver
      • register

        @RequiresPermission(allOf="android.permission.RECEIVE_BOOT_COMPLETED")
        public static Closeable register​(android.content.Context context,
                                         int jobId,
                                         int intervalMs)
        Registers polling for Tapkey notifications. The given jobId must be application-wide. The interval is approximate. The decision when the job will be executed will be made by Android itself and depends of several factors like battery level, network connection, etc.
        Parameters:
        context - the Android Context.
        jobId - an application-wide unique job ID.
        intervalMs - the polling interval.
        Returns:
        a Closable which can deregister services and receivers. ToDo: Document why RECEIVE_BOOT_COMPLETED permission is required