Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Awareness API

Introduction to Awareness API

In this talk, I'm explaining about Awareness API based on a Google I/O session - Introducing the Awareness API, an easy way to make your apps context aware (https://www.youtube.com/watch?v=37ia7S4Lsv4)

Reference:
- developers.google.com/awareness
- developers.google.com/awareness-location

Hiroshi Kurokawa

June 10, 2016
Tweet

More Decks by Hiroshi Kurokawa

Other Decks in Technology

Transcript

  1. ͳʹ͕خ͍͔͠ ݸਓͷײ૝Ͱ͢ w Ϣʔβʔͷਓʹਓ͸ΞϓϦΛճར༻ͯ͠཭୤   w Ϧςϯγϣϯͷखஈ͕ओʹϓογϡ௨஌΍ϝʔϧ
 ˠεύϜԽ͠΍͍͢ w

    Ϣʔβʔɺ࡞Γख૒ํʹͱͬͯϝϦοτ͕͋Δ  IUUQKQUFDIDSVODIDPNOFBSMZJOQFPQMFBCBOEPONPCJMFBQQTBGUFSPOMZPOFVTF
  2. 'FODF"1*  // Create awareness fence. AwarenessFence startDriving = DetectedActivityFence.starting(DetectedActivityFence.IN_VEICHLE);

    FenceUpdateRequest fenceUpdateRequest = new FenceUpdateRequest.Builder() .addFence("startDriving", startDriving, pendingIntent) .build();
  3. 'FODF"1*  // Create awareness fence. AwarenessFence startDriving = DetectedActivityFence.starting(DetectedActivityFence.IN_VEICHLE);

    FenceUpdateRequest fenceUpdateRequest = new FenceUpdateRequest.Builder() .addFence("startDriving", startDriving, pendingIntent) .build(); Awareness.FenceApi.updateFences(googleApiClient, fenceUpdateRequest);
  4. 'FODF"1*૊Έ߹Θͤ  AwarenessFence areaAroundStore = LocationFence.in(STORE_LATITUDE, STORE_LONGITUDE, 1000 /* radius

    in meters */, 0L /* dwell time */ ); AwarenessFence duringDriving = DetectedActivityFence.during(DetectedActivityFence.IN_VEICHLE);
  5. 'FODF"1*૊Έ߹Θͤ  AwarenessFence areaAroundStore = LocationFence.in(STORE_LATITUDE, STORE_LONGITUDE, 1000 /* radius

    in meters */, 0L /* dwell time */ ); AwarenessFence duringDriving = DetectedActivityFence.during(DetectedActivityFence.IN_VEICHLE); AwarenessFence openHours = TimeFence.inDailyInterval(TimeZone.getDefault(), 10 * HOURS_IN_MILLIS, 18 * HOURS_IN_MILLIS);
  6. 'FODF"1*૊Έ߹Θͤ  AwarenessFence areaAroundStore = LocationFence.in(STORE_LATITUDE, STORE_LONGITUDE, 1000 /* radius

    in meters */, 0L /* dwell time */ ); AwarenessFence duringDriving = DetectedActivityFence.during(DetectedActivityFence.IN_VEICHLE); AwarenessFence openHours = TimeFence.inDailyInterval(TimeZone.getDefault(), 10 * HOURS_IN_MILLIS, 18 * HOURS_IN_MILLIS); AwarenessFence drivingNearStore = AwarenessFence.and(areaAroundStore, duringDriving, openHours);
  7. 'FODF"1*ෳ਺ొ࿥  // Create FenceUpdateRequest and register FenceUpdateRequest fenceUpdateRequest =

    new FenceUpdateRequest.Builder() .addFence("startDriving", startDriving, pendingIntent) .addFence("drivingNearStore", drivingNearStore, pendingIntent) .build(); Awareness.FenceApi.updateFences(googleApiClient, fenceUpdateRequest);
  8. 'FODF"1*3FDFJWFS  void onReceive(Context context, Intent intent) { FenceState fenceState

    = FenceState.extract(intent); if (fenceState.getFenceKey().equals("startDriving")) { if (fenceState.getCurrentState() == FenceState.TRUE) { // show maps apps } } }
  9. 'FODF"1*3FDFJWFS  void onReceive(Context context, Intent intent) { FenceState fenceState

    = FenceState.extract(intent); if (fenceState.getFenceKey().equals("startDriving")) { if (fenceState.getCurrentState() == FenceState.TRUE) { // show maps apps } } else if (fenceState.getFenceKey().equals("drivingNearStore")) { if (fenceState.getCurrentState() == FenceState.TRUE) { // show reminder } } }