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

AwarenessAPI

 AwarenessAPI

8928b5277aa7234dbca4ff782952343a?s=128

funnelbit

July 27, 2016
Tweet

More Decks by funnelbit

Other Decks in Technology

Transcript

  1. "XBSFOFTT"1* "OESPJE

  2. ࣗݾ঺հ ๺ଜྋ גࣜձࣾ͸ͯͳ )BUFOBGVOOFMCJU 5XJUUFS!FYQFSPQFSP

  3. Ϣʔβͷ ͓͔Ε͍ͯΔ ঢ়گΛ஌Δ

  4. ెา͔ɺࣗసं͔

  5. ెา͔ɺࣗసं͔า͍͍ͯ Δͷ͔ɺ૸͍ͬͯΔͷ͔ɺࢭ ·͍ͬͯΔͷ͔

  6. ెา͔ɺࣗసं͔า͍͍ͯΔͷ͔ɺ૸ͬ ͍ͯΔͷ͔ɺࢭ·͍ͬͯΔͷ͔ͱ͋Δൣ ғ಺ʹೖ͔ͬͨɺͱ͋Δൣғ಺ʹ/ඵډଓ ͚͍ͯΔ͔ɺͱ͋Δൣғ಺͔Β཭୤͔ͨ͠

  7. ెา͔ɺࣗసं͔ɺ৐Γ෺͔า͍͍ͯΔͷ͔ɺ૸ͬ ͍ͯΔͷ͔ɺࢭ·͍ͬͯΔͷ͔ͱ͋Δൣғ಺ʹೖͬ ͔ͨɺͱ͋Δൣғ಺ʹ/ඵډଓ͚͍ͯΔ͔ɺͱ͋Δ ൣғ಺͔Β཭୤͔ͨ͋͠Δ৔ॴ͔Β/ϝʔτϧҠ ಈͨ͠ͱ͋ΔϏʔίϯ͕ݟ͔ͭͬͨɺͱ͋ΔϏʔ ίϯ͕ݟ͔ͭΒͳ͘ͳͬͨͱ͋Δ͔࣌ؒΒҰఆ࣌ ؒܦաͨ͠ϔουϗϯΛ͍ͯ͞͠Δɺͦ͏Ͱͳ͍ ੖ΕͰ͋ΔɻઇͰ͋ΔɻӍͰ͋Δͱಉ࣌ʹɺڧ෩ Ͱ͋ΔɻԹ౓ͱ࣪౓ɻFUDʜ

  8. "XBSFOFTT"1* w Ϣʔβͷঢ়گΛಡΈऔΔ"1* w ࣮૷ָ͕ w ʮਖ਼͍͠ʯσʔλ͕ಘΒΕΔͱ͍ͯ͠Δ w ϝϞϦɺόοςϦʔͷঢ়گΛݟͯಈ͘

  9. "XBSFOFTT"1* w 6TF(PPHMF1MBZ4FSWJDFTWd w &OBCMF"XBSFOFTT"1* w "EEJUJPOBM"1* &OBCMF1MBDFT"1*GPS "OESPJE w

    "EEJUJPOBM"1* &OBCMF/FBSCZ.FTTBHFT "1*
  10. "XBSFOFTT"1* mGoogleApiClient = new GoogleApiClient.Builder(this)
 .addApi(Awareness.API)
 .enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {


    @Override
 public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
 Log.e("onConnectionFailed", "failed");
 }
 })
 .build();
  11. 4OBQTIPU"1* 'FODF"1*

  12. 4OBQTIPU"1*

  13. 4OBQTIPU"1* w ௚ۙͷঢ়گΛऔಘ͢Δ w ݱࡏϢʔβ͸ϔουϗϯΛ࢖͍ͬͯΔ w ݱࡏϢʔβ͕͍Δ৔ॴ w ݱࡏϢʔβ͕͍Δ৔ॴͷఱؾ w

    FUDʜ
  14. )FBEQIPOF Awareness.SnapshotApi
 .getHeadphoneState(mGoogleApiClient)
 .setResultCallback(new ResultCallback<HeadphoneStateResult>() {
 @Override
 public void onResult(@NonNull

    HeadphoneStateResult headphoneStateResult) {
 switch (headphoneStateResult.getHeadphoneState().getState()) {
 case HeadphoneState.PLUGGED_IN :
 Log.e("ϔουϗϯ", "ૠ͍ͯ͠Δ");
 break;
 case HeadphoneState.UNPLUGGED:
 Log.e("ϔουϗϯ", "ૠ͍ͯ͠ͳ͍");
 break;
 }
 }
 });
  15. 8FBUIFS Awareness.SnapshotApi
 .getWeather(mGoogleApiClient)
 .setResultCallback(new ResultCallback<WeatherResult>() {
 @Override
 public void onResult(@NonNull

    WeatherResult weatherResult) {
 if (weatherResult.getWeather() == null) return; weatherResult.getWeather() .getConditions()
 }
 });
  16. 8FBUIFSHFU$POEJUJPOT ɾJOU<>ͰఱؾΛฦ͢ $0/%*5*0/@6/,/08/ $0/%*5*0/@$-&"3  $0/%*5*0/@$-06%: $0/%*5*0/@'0((:  $0/%*5*0/@)";: $0/%*5*0/@*$:

     $0/%*5*0/@3"*/: $0/%*5*0/@4/08:  $0/%*5*0/@4503.: PS$0/%*5*0/@8*/%:
  17. 'FODF"1*

  18. 'FODF"1* w ঢ়ଶʹมԽ͕͋Ε͹௨஌ w Ϣʔβ͕า͖࢝Ίͨ w Ϣʔβ͕ࣗసंͰҠಈ͍ͯ͠Δ w Ϣʔβ͕ͱ͋ΔΤϦΞ͔Β཭୤ͨ͠ w

    FUDʜ
  19. TUBSU8BMLJOH AwarenessFence startWakingFence = DetectedActivityFence .starting(DetectedActivityFence.WALKING);

  20. VQEBUF'FODFT Awareness.FenceApi.updateFences(mGoogleApiClient,
 new FenceUpdateRequest.Builder()
 .addFence("startWakingFence", startWakingFence, pendingIntent)
 .build())
 .setResultCallback(new ResultCallback<Status>()

    {
 @Override
 public void onResult(@NonNull Status status) {
 if (!status.isSuccess()) {…}
 }
 });
  21. 'FODF6QEBUF3FRVFTU Awareness.FenceApi.updateFences(mGoogleApiClient,
 new FenceUpdateRequest.Builder()
 .addFence("startWakingFence", startWakingFence, pendingIntent)
 .build())
 .setResultCallback(new ResultCallback<Status>()

    {
 @Override
 public void onResult(@NonNull Status status) {
 if (!status.isSuccess()) {…}
 }
 });
  22. #SPBEDBTU3FDFJWFS public class MyFenceReceiver extends BroadcastReceiver { … @Override
 public

    void onReceive(Context context, Intent intent) { if (TextUtils.equals(fenceState.getFenceKey(), "startWakingFence")) {
 switch(fenceState.getCurrentState()) {
 case FenceState.TRUE:…
 case FenceState.FALSE:…
 case FenceState.UNKNOWN:…
 …
 }
 } …
  23. $PNCJOBUJPO'FODF

  24. $PNCJOBUJPO'FODF AwarenessFence.and(
 DetectedActivityFence .during(DetectedActivityFence.WALKING),
 HeadphoneFence .during(HeadphoneState.PLUGGED_IN)
 ); า͍͓ͯΓɺϔουϗϯΛ͚͍ͭͯΔ

  25. $PNCJOBUJPO'FODF AwarenessFence walkingAndPlugInHeadPhoneFence = AwarenessFence.and(
 DetectedActivityFence.during(DetectedActivityFence.WALKING) ,
 HeadphoneFence.during(HeadphoneState.PLUGGED_IN),
 AwarenessFence.not(LocationFence.in(35.010974, 135.7612923,

    50, 0L))
 ); า͍͓ͯΓɺϔουϗϯΛ͚͍ͭͯΔ͕ɺͱ͋Δ৔ॴͷ൒ܘN಺ ʹ͸͍ͳ͍
  26. $PNCJOBUJPO'FODF AwarenessFence.or(AwarenessFence.and(
 DetectedActivityFence.during(DetectedActivityFence.WALKING) ,
 HeadphoneFence.during(HeadphoneState.PLUGGED_IN),
 AwarenessFence.not(LocationFence.in(35.010974, 135.7612923, 50, 0L))
 ),

    BeaconFence.found(…)); า͍͓ͯΓɺϔουϗϯΛ͚͍ͭͯΔ͕ɺͱ͋Δ৔ॴͷ൒ܘN಺ ʹ͸͍ͳ͍ɻ·ͨ͸ɺͱ͋ΔϏʔίϯ͕ͦ͹ʹݟ͔ͭͬͨɻ
  27. ॴײ w ʮݡ͍ʯػೳΛ࡞Δͷ͕༰қʹͳͬͨ w ͜Μͳʹ؆୯ͳΒ࢖ͬͯΈΑ͏͔ͱ͍͏ؾʹͳ Δ w Ͳ͏͏·͘࢖͏͔͸ߟ͑Δඞཁ͕͋Δ

  28. ৄࡉ w IUUQTEFWFMPQFSTHPPHMFDPNBXBSFOFTT w IUUQTEFWFMPQFSTHPPHMFDPNBOESPJE SFGFSFODFDPNHPPHMFBOESPJEHNT BXBSFOFTTQBDLBHFTVNNBSZ w IUUQTEFWFMPQFSTHPPHMFDPNBOESPJE HVJEFTSFMFBTFTKVOF@@@W

  29. ͋Γ͕ͱ͏͍͟͝·ͨ͠