Example #1
0
 /**
  * Respond to "Stop" button by canceling updates.
  *
  * @param view The view that triggered this method.
  */
 public void onStopUpdates(View view) {
   if (!servicesConnected()) {
     return;
   }
   mRequestType = ActivityUtils.REQUEST_TYPE.REMOVE;
   mDetectionRemover.removeUpdates(mDetectionRequester.getRequestPendingIntent());
   mDetectionRequester.getRequestPendingIntent().cancel();
 }
Example #2
0
 /**
  * Respond to "Start" button by requesting activity recognition updates.
  *
  * @param view The view that triggered this method.
  */
 public void onStartUpdates(View view) {
   if (!servicesConnected()) {
     return;
   }
   mRequestType = ActivityUtils.REQUEST_TYPE.ADD;
   mDetectionRequester.requestUpdates();
 }
Example #3
0
 /*
  * Handle results returned to this Activity by other Activities started with
  * startActivityForResult(). In particular, the method onConnectionFailed()
  * in DetectionRemover and DetectionRequester may call
  * startResolutionForResult() to start an Activity that handles Google Play
  * services problems. The result of this call returns here, to
  * onActivityResult.
  */
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
   switch (requestCode) {
     case ActivityUtils.CONNECTION_FAILURE_RESOLUTION_REQUEST:
       switch (resultCode) {
         case Activity.RESULT_OK:
           if (ActivityUtils.REQUEST_TYPE.ADD == mRequestType) {
             mDetectionRequester.requestUpdates();
           } else if (ActivityUtils.REQUEST_TYPE.REMOVE == mRequestType) {
             mDetectionRemover.removeUpdates(mDetectionRequester.getRequestPendingIntent());
           }
           break;
         default:
           Log.d(ActivityUtils.APPTAG, getString(R.string.no_resolution));
       }
     default:
       Log.d(ActivityUtils.APPTAG, getString(R.string.unknown_activity_request_code, requestCode));
       break;
   }
 }