private void registerIntent() { if (mRecognitionPendingIntent == null) { Intent intent = new Intent(mApplicationContext, SKActivityRecognitionIntentService.class); mRecognitionPendingIntent = PendingIntent.getService( mApplicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); } mActivityRecognition.requestActivityUpdates(mClient, 0, mRecognitionPendingIntent); }
private void unregisterIntent() { mActivityRecognition.removeActivityUpdates(mClient, mRecognitionPendingIntent); mRecognitionPendingIntent.cancel(); mRecognitionPendingIntent = null; }