com.google.android.gms.location.DetectedActivity Java Examples
The following examples show how to use
com.google.android.gms.location.DetectedActivity.
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: BackgroundActivity.java From background-geolocation-android with Apache License 2.0 | 6 votes |
public static String getActivityString(int detectedActivityType) { switch(detectedActivityType) { case DetectedActivity.IN_VEHICLE: return "IN_VEHICLE"; case DetectedActivity.ON_BICYCLE: return "ON_BICYCLE"; case DetectedActivity.ON_FOOT: return "ON_FOOT"; case DetectedActivity.RUNNING: return "RUNNING"; case DetectedActivity.STILL: return "STILL"; case DetectedActivity.TILTING: return "TILTING"; case DetectedActivity.UNKNOWN: return "UNKNOWN"; case DetectedActivity.WALKING: return "WALKING"; default: return "UNKNOWN"; } }
Example #2
Source File: AndroidActivityRecognitionWrapper.java From gsn with GNU General Public License v3.0 | 6 votes |
public static String getType(double type) { if (type == DetectedActivity.UNKNOWN) return "Unknown"; else if (type == DetectedActivity.IN_VEHICLE) return "In Vehicle"; else if (type == DetectedActivity.ON_BICYCLE) return "On Bicycle"; else if (type == DetectedActivity.ON_FOOT) return "On Foot"; else if (type == DetectedActivity.STILL) return "Still"; else if (type == DetectedActivity.TILTING) return "Tilting"; else return ""; }
Example #3
Source File: DetectionService.java From react-native-activity-recognition with GNU General Public License v2.0 | 6 votes |
public static String getActivityString(int detectedActivityType) { switch(detectedActivityType) { case DetectedActivity.IN_VEHICLE: return "IN_VEHICLE"; case DetectedActivity.ON_BICYCLE: return "ON_BICYCLE"; case DetectedActivity.ON_FOOT: return "ON_FOOT"; case DetectedActivity.RUNNING: return "RUNNING"; case DetectedActivity.STILL: return "STILL"; case DetectedActivity.TILTING: return "TILTING"; case DetectedActivity.UNKNOWN: return "UNKNOWN"; case DetectedActivity.WALKING: return "WALKING"; default: return "UNIDENTIFIABLE"; } }
Example #4
Source File: SKActivity.java From SensingKit-Android with GNU Lesser General Public License v3.0 | 6 votes |
private DetectedActivity getActivity(ActivityRecognitionResult result) { // Get the most probable activity from the list of activities in the result DetectedActivity mostProbableActivity = result.getMostProbableActivity(); // If the activity is ON_FOOT, choose between WALKING or RUNNING if (mostProbableActivity.getType() == DetectedActivity.ON_FOOT) { // Iterate through all possible activities. The activities are sorted by most probable activity first. for (DetectedActivity activity : result.getProbableActivities()) { if (activity.getType() == DetectedActivity.WALKING || activity.getType() == DetectedActivity.RUNNING) { return activity; } } // It is ON_FOOT, but not sure if it is WALKING or RUNNING Log.i(TAG, "Activity ON_FOOT, but not sure if it is WALKING or RUNNING."); return mostProbableActivity; } else { return mostProbableActivity; } }
Example #5
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 6 votes |
private void detectActivity() { Awareness.SnapshotApi.getDetectedActivity(mGoogleApiClient) .setResultCallback(new ResultCallback<DetectedActivityResult>() { @Override public void onResult(@NonNull DetectedActivityResult detectedActivityResult) { ActivityRecognitionResult result = detectedActivityResult.getActivityRecognitionResult(); Log.e("Tuts+", "time: " + result.getTime()); Log.e("Tuts+", "elapsed time: " + result.getElapsedRealtimeMillis()); Log.e("Tuts+", "Most likely activity: " + result.getMostProbableActivity().toString()); for( DetectedActivity activity : result.getProbableActivities() ) { Log.e("Tuts+", "Activity: " + activity.getType() + " Liklihood: " + activity.getConfidence() ); } } }); }
Example #6
Source File: Utils.java From location-samples with Apache License 2.0 | 6 votes |
/** * Returns a human readable String corresponding to a detected activity type. */ static String getActivityString(Context context, int detectedActivityType) { Resources resources = context.getResources(); switch(detectedActivityType) { case DetectedActivity.IN_VEHICLE: return resources.getString(R.string.in_vehicle); case DetectedActivity.ON_BICYCLE: return resources.getString(R.string.on_bicycle); case DetectedActivity.ON_FOOT: return resources.getString(R.string.on_foot); case DetectedActivity.RUNNING: return resources.getString(R.string.running); case DetectedActivity.STILL: return resources.getString(R.string.still); case DetectedActivity.TILTING: return resources.getString(R.string.tilting); case DetectedActivity.UNKNOWN: return resources.getString(R.string.unknown); case DetectedActivity.WALKING: return resources.getString(R.string.walking); default: return resources.getString(R.string.unidentifiable_activity, detectedActivityType); } }
Example #7
Source File: DetectedActivitiesIntentService.java From location-samples with Apache License 2.0 | 6 votes |
/** * Handles incoming intents. * @param intent The Intent is provided (inside a PendingIntent) when requestActivityUpdates() * is called. */ @SuppressWarnings("unchecked") @Override protected void onHandleIntent(Intent intent) { ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent); // Get the list of the probable activities associated with the current state of the // device. Each activity is associated with a confidence level, which is an int between // 0 and 100. ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities(); PreferenceManager.getDefaultSharedPreferences(this) .edit() .putString(Constants.KEY_DETECTED_ACTIVITIES, Utils.detectedActivitiesToJson(detectedActivities)) .apply(); // Log each activity. Log.i(TAG, "activities detected"); for (DetectedActivity da: detectedActivities) { Log.i(TAG, Utils.getActivityString( getApplicationContext(), da.getType()) + " " + da.getConfidence() + "%" ); } }
Example #8
Source File: BackgroundService.java From BackPackTrackII with GNU General Public License v3.0 | 6 votes |
private static void startActivityRecognition(final Context context) { if (Util.hasPlayServices(context)) { GoogleApiClient gac = new GoogleApiClient.Builder(context).addApi(ActivityRecognition.API).build(); if (gac.blockingConnect().isSuccess()) { Log.i(TAG, "GoogleApiClient connected"); Intent activityIntent = new Intent(context, BackgroundService.class); activityIntent.setAction(BackgroundService.ACTION_ACTIVITY); PendingIntent pi = PendingIntent.getService(context, 0, activityIntent, PendingIntent.FLAG_UPDATE_CURRENT); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean still = (prefs.getInt(SettingsFragment.PREF_LAST_ACTIVITY, DetectedActivity.STILL) == DetectedActivity.STILL); String setting = (still ? SettingsFragment.PREF_RECOGNITION_INTERVAL_STILL : SettingsFragment.PREF_RECOGNITION_INTERVAL_MOVING); String standard = (still ? SettingsFragment.DEFAULT_RECOGNITION_INTERVAL_STILL : SettingsFragment.DEFAULT_RECOGNITION_INTERVAL_MOVING); int interval = Integer.parseInt(prefs.getString(setting, standard)); ActivityRecognition.ActivityRecognitionApi.requestActivityUpdates(gac, interval * 1000, pi); Log.i(TAG, "Activity updates frequency=" + interval + "s"); } } }
Example #9
Source File: BackgroundService.java From BackPackTrackII with GNU General Public License v3.0 | 6 votes |
public static String getActivityName(int activityType, Context context) { switch (activityType) { case DetectedActivity.STILL: return context.getString(R.string.still); case DetectedActivity.TILTING: return context.getString(R.string.tilting); case DetectedActivity.ON_FOOT: return context.getString(R.string.on_foot); case DetectedActivity.WALKING: return context.getString(R.string.walking); case DetectedActivity.RUNNING: return context.getString(R.string.running); case DetectedActivity.ON_BICYCLE: return context.getString(R.string.on_bicycle); case DetectedActivity.IN_VEHICLE: return context.getString(R.string.in_vehicle); case DetectedActivity.UNKNOWN: return context.getString(R.string.unknown); case -1: return context.getString(R.string.motion); case -2: return context.getString(R.string.displacement); default: return context.getString(R.string.undefined); } }
Example #10
Source File: HARecognizerApiLogger.java From DataLogger with MIT License | 6 votes |
public void logDetectedActivities (ArrayList<DetectedActivity> detectedActivities){ HashMap<Integer, Integer> detectedActivitiesMap = new HashMap<>(); for (DetectedActivity activity : detectedActivities) { detectedActivitiesMap.put(activity.getType(), activity.getConfidence()); } // Timestamp in system nanoseconds since boot, including time spent in sleep. long nanoTime = SystemClock.elapsedRealtimeNanos() + mNanosOffset; // System local time in millis long currentMillis = (new Date()).getTime(); String message = String.format("%s", currentMillis) + ";" + String.format("%s", nanoTime) + ";" + String.format("%s", mNanosOffset); for (int i = 0; i < Constants.API_ACTIVITY_RECOGNIZER_LIST.length; i++) { message += ";" + Integer.toString( detectedActivitiesMap.containsKey(Constants.API_ACTIVITY_RECOGNIZER_LIST[i]) ? detectedActivitiesMap.get(Constants.API_ACTIVITY_RECOGNIZER_LIST[i]) : 0); } log(message); log(System.lineSeparator()); }
Example #11
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 6 votes |
@SmallTest public void test2DuplicateActivityEventsCreates1DataPoints() { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.RUNNING); _sessionManager.addDataPoint(3000, DetectedActivity.RUNNING); _sessionManager.saveActiveSession(4000); DataSet dataSet = getDataSet(); assertEquals(1,dataSet.getDataPoints().size()); assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 4000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.RUNNING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity()); }
Example #12
Source File: BackgroundLocationUpdateService.java From cordova-background-geolocation-services with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent); ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities(); //Find the activity with the highest percentage lastActivity = Constants.getProbableActivity(detectedActivities); Log.w(TAG, "MOST LIKELY ACTIVITY: " + Constants.getActivityString(lastActivity.getType()) + " " + lastActivity.getConfidence()); Intent mIntent = new Intent(Constants.CALLBACK_ACTIVITY_UPDATE); mIntent.putExtra(Constants.ACTIVITY_EXTRA, detectedActivities); getApplicationContext().sendBroadcast(mIntent); Log.w(TAG, "Activity is recording" + isRecording); if(lastActivity.getType() == DetectedActivity.STILL && isRecording) { showDebugToast(context, "Detected Activity was STILL, Stop recording"); stopRecording(); } else if(lastActivity.getType() != DetectedActivity.STILL && !isRecording) { showDebugToast(context, "Detected Activity was ACTIVE, Start Recording"); startRecording(); } //else do nothing }
Example #13
Source File: MainActivity.java From Wrox-ProfessionalAndroid-4E with Apache License 2.0 | 6 votes |
private void listing15_28() { // Listing 15-28: Retrieving Snapshot context signal results Awareness.SnapshotApi.getDetectedActivity(mGoogleApiClient) .setResultCallback(new ResultCallback<DetectedActivityResult>() { @Override public void onResult(@NonNull DetectedActivityResult detectedActivityResult) { if (!detectedActivityResult.getStatus().isSuccess()) { Log.e(TAG, "Current activity unknown."); } else { ActivityRecognitionResult ar = detectedActivityResult.getActivityRecognitionResult(); DetectedActivity probableActivity = ar.getMostProbableActivity(); // TODO: Do something with the detected user activity. } } }); }
Example #14
Source File: ActivityRecognitionIntentService.java From android-notification-log with MIT License | 6 votes |
private String getActivityString(int detectedActivityType) { switch(detectedActivityType) { case DetectedActivity.IN_VEHICLE: return "IN_VEHICLE"; case DetectedActivity.ON_BICYCLE: return "ON_BICYCLE"; case DetectedActivity.ON_FOOT: return "ON_FOOT"; case DetectedActivity.RUNNING: return "RUNNING"; case DetectedActivity.STILL: return "STILL"; case DetectedActivity.TILTING: return "TILTING"; case DetectedActivity.UNKNOWN: return "UNKNOWN"; case DetectedActivity.WALKING: return "WALKING"; default: return detectedActivityType + ""; } }
Example #15
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 6 votes |
@SmallTest public void test2UniqueActivityEventsCreates2DataPoints() { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.RUNNING); _sessionManager.addDataPoint(3000, DetectedActivity.WALKING); _sessionManager.saveActiveSession(4000); DataSet dataSet = getDataSet(); assertEquals(2,dataSet.getDataPoints().size()); assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 3000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.RUNNING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity()); assertEquals("Start time should equal data start time",3000,dataSet.getDataPoints().get(1).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 4000,dataSet.getDataPoints().get(1).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.WALKING, dataSet.getDataPoints().get(1).getValue(Field.FIELD_ACTIVITY).asActivity()); }
Example #16
Source File: ActivityRecognitionLocationProvider.java From background-geolocation-android with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent); ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities(); //Find the activity with the highest percentage lastActivity = getProbableActivity(detectedActivities); logger.debug("Detected activity={} confidence={}", BackgroundActivity.getActivityString(lastActivity.getType()), lastActivity.getConfidence()); handleActivity(lastActivity); if (lastActivity.getType() == DetectedActivity.STILL) { showDebugToast("Detected STILL Activity"); // stopTracking(); // we will delay stop tracking after position is found } else { showDebugToast("Detected ACTIVE Activity"); startTracking(); } //else do nothing }
Example #17
Source File: Constants.java From cordova-background-geolocation-services with Apache License 2.0 | 6 votes |
public static String getActivityString(int detectedActivityType) { switch(detectedActivityType) { case DetectedActivity.IN_VEHICLE: return "IN_VEHICLE"; case DetectedActivity.ON_BICYCLE: return "ON_BICYCLE"; case DetectedActivity.ON_FOOT: return "ON_FOOT"; case DetectedActivity.RUNNING: return "RUNNING"; case DetectedActivity.STILL: return "STILL"; case DetectedActivity.TILTING: return "TILTING"; case DetectedActivity.UNKNOWN: return "UNKNOWN"; case DetectedActivity.WALKING: return "WALKING"; default: return "Unknown"; } }
Example #18
Source File: Constants.java From cordova-background-geolocation-services with Apache License 2.0 | 6 votes |
public static DetectedActivity getProbableActivity(ArrayList<DetectedActivity> detectedActivities) { int highestConfidence = 0; DetectedActivity mostLikelyActivity = new DetectedActivity(0, DetectedActivity.UNKNOWN); for(DetectedActivity da: detectedActivities) { if(da.getType() != DetectedActivity.TILTING || da.getType() != DetectedActivity.UNKNOWN) { Log.w(ConstantsTAG, "Received a Detected Activity that was not tilting / unknown"); if (highestConfidence < da.getConfidence()) { highestConfidence = da.getConfidence(); mostLikelyActivity = da; } } } return mostLikelyActivity; }
Example #19
Source File: ActivityRecognitionServiceCommandTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testRespondsToNewActivityEventDoesNotStartsLocationWhenActivityRecognitonPreferenceNotSet() throws Exception { when(_sharedPreferences.getBoolean("ACTIVITY_RECOGNITION",false)).thenReturn(false); _command.execute(_app); _command.onChangeState(new ActivityRecognitionChangeState(BaseChangeState.State.START)); _command.onNewActivityEvent(new NewActivityEvent(DetectedActivity.ON_FOOT)); verify(_serviceStarter,timeout(2000).times(0)).startLocationServices(); }
Example #20
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testNewON_BICYCLEActivityEventCreates1DataPoints() { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.ON_BICYCLE); _sessionManager.saveActiveSession(3000); DataSet dataSet = getDataSet(); assertEquals(1,dataSet.getDataPoints().size()); assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 3000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.BIKING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity()); }
Example #21
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testNewWALKINGActivityEventCreates1DataPoints() { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.WALKING); _sessionManager.saveActiveSession(3000); DataSet dataSet = getDataSet(); assertEquals(1,dataSet.getDataPoints().size()); assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 3000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.WALKING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity()); }
Example #22
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testSaveActiveSessionClearsSessionData() throws Exception { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.ON_BICYCLE); _sessionManager.saveActiveSession(3000); DataSet dataSet = getDataSet(); assertEquals(0,_sessionManager.getSessionData().size()); }
Example #23
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testAddDataPointWhenActivityNotSameAsPreviousDoesAddSessionData() throws Exception { _sessionManager.startSession(1000, _mockGoogleApiClient); _sessionManager.addDataPoint(1000, DetectedActivity.ON_BICYCLE); _sessionManager.addDataPoint(1000, DetectedActivity.ON_FOOT); assertEquals(2, _sessionManager.getSessionData().size()); }
Example #24
Source File: GoogleFitSessionManagerTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testNewRUNNINGActivityEventCreates1DataPoints() { startSession(1000); _sessionManager.addDataPoint(2000, DetectedActivity.RUNNING); _sessionManager.saveActiveSession(3000); DataSet dataSet = getDataSet(); assertEquals(1,dataSet.getDataPoints().size()); assertEquals("Start time should equal data start time",2000,dataSet.getDataPoints().get(0).getStartTime(TimeUnit.MILLISECONDS)); assertEquals("End time should equal session end time", 3000,dataSet.getDataPoints().get(0).getEndTime(TimeUnit.MILLISECONDS)); assertEquals("Activity should equal unknown", FitnessActivities.RUNNING, dataSet.getDataPoints().get(0).getValue(Field.FIELD_ACTIVITY).asActivity()); }
Example #25
Source File: GoogleFitServiceCommand.java From JayPS-AndroidApp with MIT License | 5 votes |
@Subscribe public void onNewActivityEvent(NewActivityEvent event) { if(_currentStatus == BaseStatus.Status.STARTED) { switch (event.getActivityType()) { case DetectedActivity.ON_BICYCLE: case DetectedActivity.RUNNING: case DetectedActivity.WALKING: case DetectedActivity.ON_FOOT: _sessionManager.addDataPoint(new Date().getTime(), event.getActivityType()); break; } } }
Example #26
Source File: MainActivity.java From location-samples with Apache License 2.0 | 5 votes |
/** * Removes activity recognition updates using * {@link ActivityRecognitionClient#removeActivityUpdates(PendingIntent)}. Registers success and * failure callbacks. */ public void removeActivityUpdatesButtonHandler(View view) { Task<Void> task = mActivityRecognitionClient.removeActivityUpdates( getActivityDetectionPendingIntent()); task.addOnSuccessListener(new OnSuccessListener<Void>() { @Override public void onSuccess(Void result) { Toast.makeText(mContext, getString(R.string.activity_updates_removed), Toast.LENGTH_SHORT) .show(); setUpdatesRequestedState(false); // Reset the display. mAdapter.updateActivities(new ArrayList<DetectedActivity>()); } }); task.addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception e) { Log.w(TAG, "Failed to enable activity recognition."); Toast.makeText(mContext, getString(R.string.activity_updates_not_removed), Toast.LENGTH_SHORT).show(); setUpdatesRequestedState(true); } }); }
Example #27
Source File: AndroidActivityRecognitionWrapper.java From gsn with GNU General Public License v3.0 | 5 votes |
@Override public void runOnce() { if (!isRunning()) { disconnectGoogleAPI(); } else { if (mGoogleApiClient == null) { connectGoogleAPI(); } updateWrapperInfo(); if (ActivityRecognitionResult.hasResult(ActivityRecognitionService.getIntent())) { // Get the update ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(ActivityRecognitionService.getIntent()); DetectedActivity mostProbableActivity = result.getMostProbableActivity(); // Get the confidence % (probability) double confidence = mostProbableActivity.getConfidence(); // Get the type double activityType = mostProbableActivity.getType(); /* types: * DetectedActivity.IN_VEHICLE * DetectedActivity.ON_BICYCLE * DetectedActivity.ON_FOOT * DetectedActivity.STILL * DetectedActivity.UNKNOWN * DetectedActivity.TILTING */ StreamElement streamElement = new StreamElement(FIELD_NAMES, FIELD_TYPES, new Serializable[]{activityType, confidence}); postStreamElement(streamElement); } else { Log.d(TAG, "No results for AndroidActivityRecognition"); } } }
Example #28
Source File: ActivityRecognitionServiceCommandTest.java From JayPS-AndroidApp with MIT License | 5 votes |
@SmallTest public void testRespondsToNewSTILLAndActivityRecognitionSetDoesNotStartsTimer() throws Exception { when(_sharedPreferences.getBoolean("ACTIVITY_RECOGNITION",false)).thenReturn(false); _command.execute(_app); _command.onChangeState(new ActivityRecognitionChangeState(BaseChangeState.State.START)); _command.onNewActivityEvent(new NewActivityEvent(DetectedActivity.STILL)); verify(_mockTimer,timeout(2000).times(0)).setTimer(anyLong(),any(ActivityRecognitionServiceCommand.class)); }
Example #29
Source File: Utils.java From location-samples with Apache License 2.0 | 5 votes |
static ArrayList<DetectedActivity> detectedActivitiesFromJson(String jsonArray) { Type listType = new TypeToken<ArrayList<DetectedActivity>>(){}.getType(); ArrayList<DetectedActivity> detectedActivities = new Gson().fromJson(jsonArray, listType); if (detectedActivities == null) { detectedActivities = new ArrayList<>(); } return detectedActivities; }
Example #30
Source File: MainActivity.java From location-samples with Apache License 2.0 | 5 votes |
/** * Processes the list of freshly detected activities. Asks the adapter to update its list of * DetectedActivities with new {@code DetectedActivity} objects reflecting the latest detected * activities. */ protected void updateDetectedActivitiesList() { ArrayList<DetectedActivity> detectedActivities = Utils.detectedActivitiesFromJson( PreferenceManager.getDefaultSharedPreferences(mContext) .getString(Constants.KEY_DETECTED_ACTIVITIES, "")); mAdapter.updateActivities(detectedActivities); }