samedi 25 juin 2016

Starting Intents by Confidence of Activity Recognition

i'm developing an android application that recognize the activity user's fowllowing this guide. (http://code.tutsplus.com/tutorials/how-to-recognize-user-activity-with-activity-recognition--cms-25851).

I've already seen this post How to start service based on result from activity recognition

but my idea is to start some activities (that i've already created) if the result of confidence of the activity-recognition of this list is higher than the others.

private void handleDetectedActivities(List<DetectedActivity> probableActivities) {
for( DetectedActivity activity : probableActivities ) {
    switch( activity.getType() ) {
        case DetectedActivity.IN_VEHICLE: {
            Log.e( "ActivityRecogition", "In Vehicle: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.ON_BICYCLE: {
            Log.e( "ActivityRecogition", "On Bicycle: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.ON_FOOT: {
            Log.e( "ActivityRecogition", "On Foot: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.RUNNING: {
            Log.e( "ActivityRecogition", "Running: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.STILL: {
            Log.e( "ActivityRecogition", "Still: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.TILTING: {
            Log.e( "ActivityRecogition", "Tilting: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.WALKING: {
            Log.e( "ActivityRecogition", "Walking: " + activity.getConfidence() );
            break;
        }
        case DetectedActivity.UNKNOWN: {
            Log.e( "ActivityRecogition", "Unknown: " + activity.getConfidence() );
            break;
        }
    }
}

}

Example. If the IN_VEHICLE.getConfidence() is higher than ON_FOOT,WALKING, UNKNOWN,TILTING i want to start an activity. How can i do that? Thanks

Aucun commentaire:

Enregistrer un commentaire