當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。