Android Awareness API

Snapshotting your Fences for more Context




Marvin Ramin


android.content.Context?

No, your users Context!

In the beginning there was the GoogleApiClient

(Or just use Servant)

Two APIs you shall use!

  • Snapshot API
  • Fence API

What is the weather like where my user is?

  • Network Client
  • https://myfavorite.weather.api/weather?q=Hamburg,de
  • Parse JSON response
  • Use weather data

What is the weather like where my user is?


Awareness.SnapshotApi.getWeather(googleApiClient)
				

Snapshot API

  • Weather
  • Users Activity
  • Nearby Places
  • Your nearby Beacons
  • Location
  • Headphone state

The Fence API

Building a Fence


HeadphoneFence.during(HeadphoneState.PLUGGED_IN)
				

Building a Fence (cont.)


AwarenessFence.and(HeadphoneFence.during(PLUGGED_IN), LocationFence.entering(lat, lng, radius))
				

Register your fence


FenceUpdateRequest fenceUpdateRequest = new FenceUpdateRequest.Builder()
        .addFence("name", fence, pendingIntent)
        .build();

Awareness.FenceApi.updateFences(googleApiClient, fenceUpdateRequest)
				

Receive your result!

PendingIntent

FenceState

Fence API

Location

Activity

Headphone state

Beacons

Too much code, too many callbacks

ReactiveAwareness



reactiveSnapshot.getWeather(context).subscribe(/**/)
				


ObservableFence.create(context, fence).subscribe(/**/)
				

Reading material

Thank you!


   @Mauin
     github.com/mauin