Search in sources :

Example 1 with EventRescheduler

use of com.optimizely.ab.android.event_handler.EventRescheduler in project android-sdk by optimizely.

the class APISamplesInJava method samplesForDoc_EventDispatcher.

public static void samplesForDoc_EventDispatcher(Context context) {
    // -- sample starts here
    // Using an anonymous class here to implement the EventHandler interface.
    // Feel free to create an explicit class that implements the interface instead.
    EventHandler eventHandler = new EventHandler() {

        @Override
        public void dispatchEvent(LogEvent logEvent) throws Exception {
        // Send event to our log endpoint as documented in
        // https://developers.optimizely.com/x/events/api/index.html
        }
    };
    // Build a manager
    OptimizelyManager optimizelyManager = OptimizelyManager.builder().withSDKKey("<Your_SDK_Key>").withEventDispatchInterval(60, TimeUnit.SECONDS).withEventHandler(eventHandler).build(context);
    // With the new Android O differences, you need to register the
    // service for the intent filter you desire in code instead of in the manifest.
    EventRescheduler eventRescheduler = new EventRescheduler();
    context.registerReceiver(eventRescheduler, new IntentFilter(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION));
}
Also used : IntentFilter(android.content.IntentFilter) LogEvent(com.optimizely.ab.event.LogEvent) EventRescheduler(com.optimizely.ab.android.event_handler.EventRescheduler) EventHandler(com.optimizely.ab.event.EventHandler) DefaultEventHandler(com.optimizely.ab.android.event_handler.DefaultEventHandler) OptimizelyManager(com.optimizely.ab.android.sdk.OptimizelyManager)

Aggregations

IntentFilter (android.content.IntentFilter)1 DefaultEventHandler (com.optimizely.ab.android.event_handler.DefaultEventHandler)1 EventRescheduler (com.optimizely.ab.android.event_handler.EventRescheduler)1 OptimizelyManager (com.optimizely.ab.android.sdk.OptimizelyManager)1 EventHandler (com.optimizely.ab.event.EventHandler)1 LogEvent (com.optimizely.ab.event.LogEvent)1