Interface TapkeyAppContext


  • public interface TapkeyAppContext
    The Application class of an Android app using the Tapkey Mobile SDK must implement this interface. It provides access to the instance of TapkeyServiceFactory. Applications usually build the TapkeyServiceFactory within the Application.onCreate() method and hold it as singleton instance. The getTapkeyServiceFactory() method allows accessing it from components like services and broadcast receivers. The example below outlines an Application that implements this interface:
     public class App extends Application implements TapkeyAppContext {
    
         /*
          * The TapkeyServiceFactory holds all required services.
          */
         private TapkeyServiceFactory tapkeyServiceFactory;
    
         @Override
         public void onCreate() {
             super.onCreate();
    
             /*
              * Create an instance of TapkeyServiceFactory. Tapkey expects that a single instance of
              * TapkeyServiceFactory exists inside an application that can be retrieved via the
              * Application instance's getTapkeyServiceFactory() method.
              */
             TapkeyServiceFactoryBuilder b = new TapkeyServiceFactoryBuilder();
             this.tapkeyServiceFactory = b.build(this);
    
             /*
              * Register the polling scheduler.
              * The polling scheduler polls for notifications from the Tapkey Trust Service. Note that
              * the job ID must be unique across the whole app. The default interval is 8 hours.
              */
             PollingScheduler.register(this, 1, PollingScheduler.DEFAULT_INTERVAL);
         }
    
         @Override
         public TapkeyServiceFactory getTapkeyServiceFactory() {
             return tapkeyServiceFactory;
         }
     }
     
    See Also:
    TapkeyServiceFactory