當前位置: 首頁>>代碼示例>>Java>>正文


Java DetectedActivity.getType方法代碼示例

本文整理匯總了Java中com.google.android.gms.location.DetectedActivity.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java DetectedActivity.getType方法的具體用法?Java DetectedActivity.getType怎麽用?Java DetectedActivity.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.android.gms.location.DetectedActivity的用法示例。


在下文中一共展示了DetectedActivity.getType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProbableActivity

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
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;
}
 
開發者ID:pmwisdom,項目名稱:cordova-background-geolocation-services,代碼行數:17,代碼來源:Constants.java

示例2: onActivityChange

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@Override
public IState onActivityChange(DetectedActivity activity) {
    if (activity.getType() == DetectedActivity.IN_VEHICLE) {
        //TODO(aantoine): inCooldown first instant velocity!
        //return new NotificationState(this, this.busStop.getIncomingBuses());
        this.checkForInstantVelocity = true;
        setInstantVelocityTimer();
    }
    if (activity.getType() != DetectedActivity.IN_VEHICLE ||
            activity.getType() == DetectedActivity.TILTING ||
            activity.getType() == DetectedActivity.UNKNOWN) {
        //DEFINETLY NOT IN VEHICLE!
        if (currentTask != null) {
            currentTask.cancel();
        }
        this.checkForInstantVelocity = false;
    }
    return this;
}
 
開發者ID:InspectorIncognito,項目名稱:androidApp,代碼行數:20,代碼來源:BusStopState.java

示例3: parseActivity

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
private String parseActivity(DetectedActivity activity){
  	String log;
  	
  	switch(activity.getType()){
  	case DetectedActivity.IN_VEHICLE:
  		log = "In car.";
  		break;
  	case DetectedActivity.ON_BICYCLE:
  		log = "On bike.";
  		break;
  	case DetectedActivity.ON_FOOT:
  		log = "On foot.";
  		break;
  	case DetectedActivity.STILL:
  		log = "Standing still.";
  		break;
  	case DetectedActivity.TILTING:
  		log = "Tilting.";
  		break;
default:
	log = "Unknown.";
  	}
  	
  	return activity.getConfidence() + "%:\t\t\t" + log;
  }
 
開發者ID:cictourgune,項目名稱:Pandora-sdk-android,代碼行數:26,代碼來源:PandoraSDK.java

示例4: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
    if (ActivityRecognitionResult.hasResult(intent)) {
        ActivityRecognitionResult result =
                ActivityRecognitionResult.extractResult(intent);
        DetectedActivity mostProbableActivity = result.getMostProbableActivity();
        int confidence = mostProbableActivity.getConfidence();
        int activityType = mostProbableActivity.getType();
        long waitTime = UserSettings.getNotDrivingTime(this);
        boolean diffTimeOK = (new Date().getTime() - waitTime) >= Utils.minutesToMillis(10);
        if (confidence >= Utils.DETECTION_THRESHOLD && activityType == DetectedActivity.IN_VEHICLE && diffTimeOK) {
            if (!CarMode.running) {
                if (UserSettings.getGPS(this) && ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
                    startService(new Intent(this, SpeedService.class));
                else
                    startService(new Intent(this, CarMode.class));
            }
        } else if (confidence >= Utils.DETECTION_THRESHOLD) {
            stopService(new Intent(this, CarMode.class));
            UserSettings.setGPSDrive(this, false);
        }

    }
}
 
開發者ID:kylecorry31,項目名稱:ShutUpAndDrive,代碼行數:25,代碼來源:DetectedActivityIntentService.java

示例5: onReceive

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {

	if (ActivityRecognitionResult.hasResult(intent)) {
		// Get the update
		ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
		// Get the most probable activity
		DetectedActivity mostProbableActivity = result.getMostProbableActivity();
		int confidence = mostProbableActivity.getConfidence();
		int activityType = mostProbableActivity.getType();
		String activityName = getNameFromType(activityType);
		
		DataBundle b = _bundlePool.borrowBundle();
		b.putInt(KEY_CONFIDENCE, confidence);
		b.putString(KEY_RECOGNIZED_ACTIVITY, activityName);
		b.putLong(Input.KEY_TIMESTAMP, System.currentTimeMillis());
		b.putInt(Input.KEY_TYPE, getType().toInt());
		post(b);

	}

}
 
開發者ID:participactunibo,項目名稱:MoST,代碼行數:23,代碼來源:GoogleActivityRecognitionInput.java

示例6: isMoving

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
/**
 * Detecta si el dispositivo se encuentra en un vehículo en movimiento o no
 *
 * @param result resultado de la detección de actividad
 * @return <code>true</code> si se encuentra en un vehículo.
 */
private boolean isMoving(ActivityRecognitionResult result) {
    long currentTime = System.currentTimeMillis();

    DetectedActivity mostProbableActivity = result.getMostProbableActivity();
    int confidence = mostProbableActivity.getConfidence();
    int type = mostProbableActivity.getType();

    if ((type == ON_FOOT || type == RUNNING || type == WALKING) && confidence > 75) {
        return false;
    }

    if (type == IN_VEHICLE && confidence > 75) {
        mPreferenceUtils.setDetectionTimeMillis(currentTime);
        return true;
    }

    if (mPreferenceUtils.wasMoving()) {
        long tolerance = mPreferenceUtils.getActivityRecognitionToleranceMillis();
        long lastDetectionTime = mPreferenceUtils.getDetectionTimeMillis();
        long elapsedTime = currentTime - lastDetectionTime;
        return elapsedTime <= tolerance;
    }

    return false;
}
 
開發者ID:rubenlop88,項目名稱:autotracks-android,代碼行數:32,代碼來源:ActivityRecognitionService.java

示例7: getActivity

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
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;
        }

    }
 
開發者ID:SensingKit,項目名稱:SensingKit-Android,代碼行數:27,代碼來源:SKActivity.java

示例8: runOnce

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@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");
		}
	}
}
 
開發者ID:LSIR,項目名稱:gsn,代碼行數:40,代碼來源:AndroidActivityRecognitionWrapper.java

示例9: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
/**
 * Called when a new activity detection update is available.
 */
@Override
protected void onHandleIntent(Intent intent) {
    //...
    // If the intent contains an update
    if (ActivityRecognitionResult.hasResult(intent)) {
        // Get the updatenex
        ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);

        DetectedActivity mostProbableActivity = result.getMostProbableActivity();

        // Get the confidence % (probability)
        int confidence = mostProbableActivity.getConfidence();

        // Get the type
        int activityType = mostProbableActivity.getType();

        Intent sendToLoggerIntent = new Intent("com.pinsonault.androidsensorlogger.ACTIVITY_RECOGNITION_DATA");
        sendToLoggerIntent.putExtra("Activity", activityType);
        sendToLoggerIntent.putExtra("Confidence", confidence);
        sendBroadcast(sendToLoggerIntent);
    }
}
 
開發者ID:jpinsonault,項目名稱:android_sensor_logger,代碼行數:26,代碼來源:ActivityRecognitionIntentService.java

示例10: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
    if (intent.getAction() != LocationActivity.ACTION_ACTIVITY_RECOGNITION) {
        return;
    }
    if (ActivityRecognitionResult.hasResult(intent)) {
        ActivityRecognitionResult result = ActivityRecognitionResult
                .extractResult(intent);
        DetectedActivity detectedActivity = result
                .getMostProbableActivity();
        int activityType = detectedActivity.getType();

        Log.v(LocationActivity.TAG, "activity_type == " + activityType);

        // Put the activity_type as an intent extra and send a broadcast.
        Intent send_intent = new Intent(
                LocationActivity.ACTION_ACTIVITY_RECOGNITION);
        send_intent.putExtra("activity_type", activityType);
        sendBroadcast(send_intent);
    }
}
 
開發者ID:saxman,項目名稱:maps-android-codelabs,代碼行數:22,代碼來源:ActivityRecognitionIntentService.java

示例11: logActivity

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
/**
 * Logging only
 *
 * @param detectedActivity the {@link DetectedActivity}
 */
private void logActivity(final DetectedActivity detectedActivity) {
    MyLog.v(CLS_NAME, "detectedActivity: confidence: " + detectedActivity.getConfidence());

    switch (detectedActivity.getType()) {

        case DetectedActivity.WALKING:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.WALKING");
            break;
        case DetectedActivity.IN_VEHICLE:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.IN_VEHICLE");
            break;
        case DetectedActivity.ON_BICYCLE:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.ON_BICYCLE");
            break;
        case DetectedActivity.ON_FOOT:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.ON_FOOT");
            break;
        case DetectedActivity.RUNNING:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.RUNNING");
            break;
        case DetectedActivity.STILL:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.STILL");
            break;
        case DetectedActivity.TILTING:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.TILTING");
            break;
        case DetectedActivity.UNKNOWN:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.UNKNOWN");
            break;
        default:
            MyLog.i(CLS_NAME, "detectedActivity: DetectedActivity.default");
            break;
    }
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:40,代碼來源:MotionIntentService.java

示例12: handleResult

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
private void handleResult(@NonNull DetectedActivityResult detectedActivityResult){
    ActivityRecognitionResult ar = detectedActivityResult.getActivityRecognitionResult();
    RecognizedActivityResult result = new RecognizedActivityResult();
    List<DetectedActivity> acts = ar.getProbableActivities();
    result.activities = new RecognizedActivity[acts.size()];
    for(int i = 0; i < acts.size(); ++i){
        DetectedActivity act = acts.get(i);
        result.activities[i] = new RecognizedActivity(act.getType(), act.getConfidence());
    }
    resultCallback.onResult(result);
}
 
開發者ID:TalkingData,項目名稱:Myna,代碼行數:12,代碼來源:AwarenessImpl.java

示例13: getProbableActivity

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
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(TAG, "Received a Detected Activity that was not tilting / unknown");
            if (highestConfidence < da.getConfidence()) {
                highestConfidence = da.getConfidence();
                mostLikelyActivity = da;
            }
        }
    }
    return mostLikelyActivity;
}
 
開發者ID:QuintechDevOps,項目名稱:cordova-plugin-quintech-background-geolocation,代碼行數:16,代碼來源:ActivityRecognitionLocationProvider.java

示例14: 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.
 */
@Override
protected void onHandleIntent(Intent intent) {
    int currentActivity = DetectedActivity.UNKNOWN;
    //get the message handler
    Messenger messenger = null;
    Bundle extras = intent.getExtras();
    if (extras != null) {
        messenger = (Messenger) extras.get("MESSENGER");
    }
    //get the activity info
    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.
        currentActivity = probably.getType();
    }
    Log.v(TAG, "about to send message");
    if (messenger != null) {
        Message msg = Message.obtain();
        msg.arg1 = currentActivity;
        Log.v(TAG, "Sent message");
        try {
            messenger.send(msg);
        } catch (android.os.RemoteException e1) {
            Log.w(getClass().getName(), "Exception sending message", e1);
        }
    }

}
 
開發者ID:JimSeker,項目名稱:googleplayAPI,代碼行數:37,代碼來源:DetectedActivitiesIntentService.java

示例15: onActivityChange

import com.google.android.gms.location.DetectedActivity; //導入方法依賴的package包/類
@Override
public IState onActivityChange(DetectedActivity activity) {
    if (activity.getType() != DetectedActivity.IN_VEHICLE) {
        dirty = true;
        return new WaitState(this, bus, sender);
    }
    return this;
}
 
開發者ID:InspectorIncognito,項目名稱:androidApp,代碼行數:9,代碼來源:VehicleState.java


注:本文中的com.google.android.gms.location.DetectedActivity.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。