com.google.android.gms.awareness.fence.FenceState Java Examples
The following examples show how to use
com.google.android.gms.awareness.fence.FenceState.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomTransitionsIntentService.java From JCVD with MIT License | 6 votes |
protected void onHandleIntent(Intent intent) { String notificationText; FenceState fenceState = FenceState.extract(intent); String fenceKey = fenceState.getFenceKey(); if (fenceState.getCurrentState() == FenceState.TRUE) { StorableFenceManager manager = new StorableFenceManager(this); StorableFence fence = manager.getFence(fenceKey); if (fence != null) { notificationText = "(Custom)Fence " + fenceKey + " received"; } else { notificationText = "(Custom)Fence " + fenceKey + " not found in store"; } sendNotification(notificationText); } }
Example #2
Source File: WalkFenceReceiver.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { FenceState fenceState = FenceState.extract(intent); String fenceKey = fenceState.getFenceKey(); int fenceStatus = fenceState.getCurrentState(); if (fenceKey.equals(WALK_FENCE_KEY)) { if (fenceStatus == FenceState.TRUE) { // TODO React to fence being triggered. } } }
Example #3
Source File: AwarenessMotionUpdatesProvider.java From PrivacyStreams with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if(TextUtils.equals(FENCE_RECEIVER_ACTION,intent.getAction())){ //Check if is the desired action that we are looking for FenceState fenceState = FenceState.extract(intent); switch (fenceState.getCurrentState()) { //Check the state info incase some error happened case FenceState.TRUE: Log.e(fenceState.getFenceKey(), "Active"); // When new motion has been detected, output a new physical activity output(new AwarenessMotion(System.currentTimeMillis(), fenceState.getFenceKey())); break; } } }
Example #4
Source File: MainActivity.java From android-play-awareness with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if (!TextUtils.equals(FENCE_RECEIVER_ACTION, intent.getAction())) { mLogFragment.getLogView() .println("Received an unsupported action in FenceReceiver: action=" + intent.getAction()); return; } // The state information for the given fence is em FenceState fenceState = FenceState.extract(intent); if (TextUtils.equals(fenceState.getFenceKey(), FENCE_KEY)) { String fenceStateStr; switch (fenceState.getCurrentState()) { case FenceState.TRUE: fenceStateStr = "true"; break; case FenceState.FALSE: fenceStateStr = "false"; break; case FenceState.UNKNOWN: fenceStateStr = "unknown"; break; default: fenceStateStr = "unknown value"; } mLogFragment.getLogView().println("Fence state: " + fenceStateStr); } }
Example #5
Source File: ActivityFanceApiDemo.java From android-samples with Apache License 2.0 | 5 votes |
@Override public void onReceive(final Context context, final Intent intent) { FenceState fenceState = FenceState.extract(intent); if (TextUtils.equals(fenceState.getFenceKey(), ACTIVITY_STILL_FENCE_KEY)) { switch (fenceState.getCurrentState()) { case FenceState.TRUE: //User is still mActivityFenceStatusTv.setText("You are still."); break; case FenceState.FALSE: mActivityFenceStatusTv.setText("You are moving. Keep moving.:-)"); break; case FenceState.UNKNOWN: mActivityFenceStatusTv.setText("Confused.:-("); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), ACTIVITY_MOVING_FENCE_KEY)) { switch (fenceState.getCurrentState()) { case FenceState.FALSE: mActivityFenceStatusTv.setText("You are still."); break; case FenceState.TRUE: //User is moving mActivityFenceStatusTv.setText("You are moving. Keep moving.:-)"); break; case FenceState.UNKNOWN: mActivityFenceStatusTv.setText("Confused.:-("); break; } } }
Example #6
Source File: HeadphoneFenceApiActivity.java From android-samples with Apache License 2.0 | 5 votes |
@Override public void onReceive(final Context context, final Intent intent) { FenceState fenceState = FenceState.extract(intent); if (TextUtils.equals(fenceState.getFenceKey(), HEADPHONE_PLUG_FENCE_KEY)) {//response if from headphone plug in fence switch (fenceState.getCurrentState()) { case FenceState.TRUE: //Head phones are plugged in. (Check fence register code) mHeadPhoneStatusTv.setText("Headphones connected."); break; case FenceState.FALSE: mHeadPhoneStatusTv.setText("Headphones disconnected."); break; case FenceState.UNKNOWN: mHeadPhoneStatusTv.setText("Confused.:-("); break; } } else if (TextUtils.equals(fenceState.getFenceKey(), HEADPHONE_UNPLUG_FENCE_KEY)) {//response if from headphone unplug fence switch (fenceState.getCurrentState()) { case FenceState.FALSE: mHeadPhoneStatusTv.setText("Headphones connected."); break; case FenceState.TRUE: //Head phones are unplugged. (Check fence register code) mHeadPhoneStatusTv.setText("Headphones disconnected."); break; case FenceState.UNKNOWN: mHeadPhoneStatusTv.setText("Confused.:-("); break; } } }
Example #7
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { if(TextUtils.equals(ACTION_FENCE, intent.getAction())) { FenceState fenceState = FenceState.extract(intent); if( TextUtils.equals(KEY_SITTING_AT_HOME, fenceState.getFenceKey() ) ) { if( fenceState.getCurrentState() == FenceState.TRUE ) { Log.e("Tuts+", "You've been sitting at home for too long"); } } } }