Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
app
gradle/wrapper
.gitignore
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

BroadcastReceiver Example

Overview

If you would like notifications from Engine in the app’s background state we recommend integrating Engine via BroadcastReceivers as opposed to Listeners. We provide the following abstract classes that extend BroadcastReceivers:

  • FactualActionReceiver: replaces FactualActionHandler
  • FactualClientReceiver: replaces FactualClientListener

Integration

The main difference between our Listener example and BroadcastReceiver example is that you must reference your Receivers in your AndroidManifest.xml. We do the following in our example:

...
        <receiver android:name=".ConsoleLoggingActionReceiver"/>
        <receiver android:name=".ConsoleLoggingFactualClientReceiver"/>
        <receiver android:name=".ConsoleLoggingUserJourneyReceiver"/>
    </application>
...

The ConsoleLoggingActionReceiver extends FactualActionReceiver, the ConsoleLoggingUserJourneyReceiver extends UserJourneyReceiver, and the ConsoleLoggingFactualClientReceiver extends FactualClientReceiver.

Setting or registering a receiver is also a little different, for example:

Setting the FactualClientReceiver in MainActivity.java:

...
FactualEngine.setListener(ConsoleLoggingFactualClientReceiver.class);
...

Setting the UserJourneyReceiver in MainActivity.java:

...
FactualEngine.setUserJourneyListener(ConsoleLoggingUserJourneyReceiver.class);
...

Registering the FactualActionReceiver in MainActivity.java:

...
FactualEngine.registerAction(actionId, ConsoleLoggingActionReceiver.class);
...