Skip to content

Instantly share code, notes, and snippets.

@jcbribeiro
Created March 25, 2020 22:48
Show Gist options
  • Select an option

  • Save jcbribeiro/f9c09a2d731cd87351e7330154b4ed7e to your computer and use it in GitHub Desktop.

Select an option

Save jcbribeiro/f9c09a2d731cd87351e7330154b4ed7e to your computer and use it in GitHub Desktop.
register primitive fences
fun onClick_button_register(view: View?) {
val headphoneFence: AwarenessFence = HeadphoneFence.during(HeadphoneState.PLUGGED_IN)
addFence("headphoneFence", headphoneFence)
val walkingFence: AwarenessFence = DetectedActivityFence.during(DetectedActivityFence.WALKING)
addFence("walkingFence", walkingFence)
val nowMillis = System.currentTimeMillis()
val oneMinuteMilis = 60L * 1000L
val thirtySecondsMillis = 30L * 1000L
val timeFence: AwarenessFence = TimeFence.inInterval(
nowMillis + thirtySecondsMillis, // starting in thirty seconds
nowMillis + thirtySecondsMillis + oneMinuteMilis // lasts for one minute
)
addFence("timeFence", timeFence)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment