当前位置: 首页>>代码示例>>Java>>正文


Java DetectedActivity类代码示例

本文整理汇总了Java中com.google.android.gms.location.DetectedActivity的典型用法代码示例。如果您正苦于以下问题:Java DetectedActivity类的具体用法?Java DetectedActivity怎么用?Java DetectedActivity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DetectedActivity类属于com.google.android.gms.location包,在下文中一共展示了DetectedActivity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNameFromType

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
private String getNameFromType(int activityType) {
    switch (activityType) {
        case DetectedActivity.RUNNING:
            return "running";
        case DetectedActivity.IN_VEHICLE:
            return "in_vehicle";
        case DetectedActivity.ON_BICYCLE:
            return "on_bicycle";
        case DetectedActivity.ON_FOOT:
            return "on_foot";
        case DetectedActivity.STILL:
            return "still";
        case DetectedActivity.UNKNOWN:
            return "unknown";
        case DetectedActivity.TILTING:
            return "tilting";
    }
    return "unknown";
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:DetectedActivityToString.java

示例2: onLocationChanged

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    Log.d(TAG, "onLocationChanged: " + location.toString());

    if (lastActivity.getType() == DetectedActivity.STILL) {
        stopTracking();
    }

    if (config.isDebugging()) {
        Toast.makeText(context, "acy:" + location.getAccuracy() + ",v:" + location.getSpeed() + ",df:" + config.getDistanceFilter(), Toast.LENGTH_LONG).show();
    }

    // if (lastLocation != null && location.distanceTo(lastLocation) < config.getDistanceFilter()) {
    //     return;
    // }

    if (config.isDebugging()) {
        startTone("beep");
    }

    lastLocation = location;
    handleLocation(location);
}
 
开发者ID:QuintechDevOps,项目名称:cordova-plugin-quintech-background-geolocation,代码行数:24,代码来源:ActivityRecognitionLocationProvider.java

示例3: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
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";
      }
}
 
开发者ID:QuintechDevOps,项目名称:cordova-plugin-quintech-background-geolocation,代码行数:23,代码来源:ActivityRecognitionLocationProvider.java

示例4: onReceive

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
@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);

    Log.d(TAG, "MOST LIKELY ACTIVITY: " + getActivityString(lastActivity.getType()) + " " + lastActivity.getConfidence());

    if (lastActivity.getType() == DetectedActivity.STILL) {
        if (config.isDebugging()) {
            Toast.makeText(context, "Detected STILL Activity", Toast.LENGTH_SHORT).show();
        }
        // stopTracking();
        // we will delay stop tracking after position is found
    } else {
        if (config.isDebugging()) {
            Toast.makeText(context, "Detected ACTIVE Activity", Toast.LENGTH_SHORT).show();
        }
        startTracking();
    }
    //else do nothing
}
 
开发者ID:QuintechDevOps,项目名称:cordova-plugin-quintech-background-geolocation,代码行数:25,代码来源:ActivityRecognitionLocationProvider.java

示例5: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * Returns a human readable String corresponding to a detected activity type.
 */
public 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);
    }
}
 
开发者ID:maddygy,项目名称:Activity-Recognition-Tools,代码行数:27,代码来源:Constants.java

示例6: getProbableActivities

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * Provides the current probable {@link DetectedActivity}s of the device which have at least
 * the given probability. Should no activity reach this minimum probability, the resulting list
 * will be empty.
 *
 * @param minimumProbability minimum probabilities of the activities
 * @return Single event of the most probable activities
 */
@RequiresPermission("com.google.android.gms.permission.ACTIVITY_RECOGNITION")
public Single<List<DetectedActivity>> getProbableActivities(int minimumProbability) {
    return getActivity()
            .map(activity -> {
                List<DetectedActivity> probableActivities = activity.getProbableActivities();
                List<DetectedActivity> matchingActivities = new ArrayList<>(probableActivities.size());

                for (DetectedActivity probableActivity : probableActivities) {
                    if (activity.getActivityConfidence(probableActivity.getType()) >= minimumProbability) {
                        matchingActivities.add(probableActivity);
                    }
                }

                return matchingActivities;
            });
}
 
开发者ID:Mauin,项目名称:ReactiveAwareness,代码行数:25,代码来源:ReactiveSnapshot.java

示例7: getNameFromType

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * Map detected activity types to strings
 *@param activityType The detected activity type
 *@return A user-readable name for the type
 */
private String getNameFromType(int activityType) {
    switch(activityType) {
        case DetectedActivity.IN_VEHICLE:
            return "in_vehicle";
        case DetectedActivity.ON_BICYCLE:
            return "on_bicycle";
        case DetectedActivity.ON_FOOT:
            return "on_foot";
        case DetectedActivity.STILL:
            return "still";
        case DetectedActivity.UNKNOWN:
            return "unknown";
        case DetectedActivity.TILTING:
            return "tilting";
    }
    return "unknown";
}
 
开发者ID:RobertTrebor,项目名称:CycleFrankfurtAndroid,代码行数:23,代码来源:ActivityRecognitionIntentService.java

示例8: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
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";
    }
}
 
开发者ID:Aminoid,项目名称:react-native-activity-recognition,代码行数:23,代码来源:DetectionService.java

示例9: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * 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() + "%"
        );
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:31,代码来源:DetectedActivitiesIntentService.java

示例10: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:27,代码来源:Utils.java

示例11: onNewIntent

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    Log.v(TAG, "onNewIntent");

    ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
    //get most probable activity
    DetectedActivity probably = result.getMostProbableActivity();
    if (probably.getConfidence() >= 50) {  //doc's say over 50% is likely, under is not sure at all.
        speech(getActivityString(probably.getType()));
    }
    logger.append("Most Probable: " +getActivityString(probably.getType()) + " "+ probably.getConfidence()+"%\n" );
    //or we could go through the list, which is sorted by most likely to least likely.
    List<DetectedActivity> fulllist = result.getProbableActivities();
    for (DetectedActivity da: fulllist) {
        if (da.getConfidence() >=50) {
            logger.append("-->" + getActivityString(da.getType()) + " " + da.getConfidence() + "%\n");
            speech(getActivityString(da.getType()));

        }
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:22,代码来源:MainActivity.java

示例12: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * Returns a human readable String corresponding to a detected activity type.
 */

public static String getActivityString(int detectedActivityType) {
    switch (detectedActivityType) {
        case DetectedActivity.IN_VEHICLE:
            return "In a Vehicle";
        case DetectedActivity.ON_BICYCLE:
            return "On a bicycle";
        case DetectedActivity.ON_FOOT:
            return "On Foot";
        case DetectedActivity.RUNNING:
            return "Running";
        case DetectedActivity.STILL:
            return "Still (not moving)";
        case DetectedActivity.TILTING:
            return "Tilting";
        case DetectedActivity.UNKNOWN:
            return "Unknown Activity";
        case DetectedActivity.WALKING:
            return "Walking";
        default:
            return "Unknown Type";
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:27,代码来源:MainActivity.java

示例13: getActivityPic

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
/**
 * Returns a human readable String corresponding to a detected activity type.
 */

public static int getActivityPic(int detectedActivityType) {
    switch (detectedActivityType) {
        case DetectedActivity.IN_VEHICLE:
            return R.drawable.car;
        case DetectedActivity.ON_BICYCLE:
            return R.drawable.bike;
        case DetectedActivity.ON_FOOT:
            return R.drawable.walk;
        case DetectedActivity.RUNNING:
            return R.drawable.run;
        case DetectedActivity.STILL:
            return R.drawable.still;
        case DetectedActivity.TILTING:
            return R.drawable.tilt;
        case DetectedActivity.UNKNOWN:
            return R.drawable.unknown;
        case DetectedActivity.WALKING:
            return R.drawable.walk;
        default:
            return R.drawable.unknown;
    }
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:27,代码来源:myAdapter.java

示例14: getActivityString

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
public 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);
    }
}
 
开发者ID:jamescoggan,项目名称:activity-recognition-example,代码行数:24,代码来源:Constants.java

示例15: startActivityRecognition

import com.google.android.gms.location.DetectedActivity; //导入依赖的package包/类
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");
        }
    }
}
 
开发者ID:M66B,项目名称:BackPackTrackII,代码行数:21,代码来源:BackgroundService.java


注:本文中的com.google.android.gms.location.DetectedActivity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。