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


Java DetectedActivity.getConfidence方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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) {
    ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
    Intent localIntent = new Intent(Constants.ACTIVITY_BROADCAST_ACTION);

    if (result == null) {
        return;
    }

    ArrayList<DetectedActivity> res = new ArrayList<>();
    for (DetectedActivity d : result.getProbableActivities()) {
        if (d.getConfidence() > Constants.MIN_ACTIVITY_CONFIDENCE) {
            res.add(d);
        }
    }

    // Broadcast the list of detected activities.
    localIntent.putExtra(Constants.ACTIVITY_EXTRA, res);
    LocalBroadcastManager.getInstance(this).sendBroadcast(localIntent);
}
 
开发者ID:InspectorIncognito,项目名称:androidApp,代码行数:27,代码来源:DetectedActivitiesIntentService.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例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: 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

示例11: 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

示例12: 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

示例13: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {

    // Get the ActivityRecognitionResult
    ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);

    // Get the list of the probable activities
    ArrayList<DetectedActivity> detectedActivities = (ArrayList) result.getProbableActivities();

    String type = "";
    float confidence = 0;

    // Select the most confidence type
    for (DetectedActivity da : detectedActivities) {
        if (da.getConfidence() > confidence) {
            confidence = da.getConfidence();
            type = Constants.getActivityString(
                    getApplicationContext(),
                    da.getType());
        }
    }

    // Add to the notification the current most confidence activity
    NotificationCompat.Builder mBuilder =
            new NotificationCompat.Builder(this)
                    .setSmallIcon(R.mipmap.ic_launcher)
                    .setContentTitle("Current activity: " + type)
                    .setOngoing(true)
                    .setContentText("Confidence: " + String.valueOf(confidence) + "%");
    int mNotificationId = Constants.NOTIFICATION_ID;
    NotificationManager mNotifyMgr =
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    mNotifyMgr.notify(mNotificationId, mBuilder.build());
}
 
开发者ID:jamescoggan,项目名称:activity-recognition-example,代码行数:35,代码来源:ActivityRecognitionIntentService.java

示例14: saveData

import com.google.android.gms.location.DetectedActivity; //导入方法依赖的package包/类
private void saveData(DetectedActivity mostProbableActivity){
    double samples[] = new double[2];
    samples[DataFormat.ActivityType.Confidence] = mostProbableActivity.getConfidence();
    samples[DataFormat.ActivityType.Type] = getActivityType(mostProbableActivity.getType());
    DataTypeDoubleArray dataTypeDoubleArray = new DataTypeDoubleArray(DateTime.getDateTime(), samples);
    try {
        dataKitAPI.insert(dataSourceClient, dataTypeDoubleArray);
        callBack.onReceivedData(dataTypeDoubleArray);
    } catch (DataKitException e) {
        LocalBroadcastManager.getInstance(context).sendBroadcast(new Intent(ServicePhoneSensor.INTENT_STOP));
    }

}
 
开发者ID:MD2Korg,项目名称:mCerebrum-PhoneSensor,代码行数:14,代码来源:ActivityType.java

示例15: onHandleIntent

import com.google.android.gms.location.DetectedActivity; //导入方法依赖的package包/类
/**
 * Called when a new activity detection update is available.
 */
@Override
protected void onHandleIntent(Intent intent) {
	Log.i("AS Service", "onHandleIntent: Got here!");
	if (ActivityRecognitionResult.hasResult(intent)) {
		// Get the update
		ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);

		DetectedActivity mostProbableActivity = result.getMostProbableActivity();

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

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

		// process 
		Intent broadcastIntent = new Intent(ACTIVITY_RECOGNITION_DATA);
		broadcastIntent.putExtra(ACTIVITY, activityType);
		broadcastIntent.putExtra(CONFIDENCE, confidence);
		LocalBroadcastManager.getInstance(this).sendBroadcast(broadcastIntent);

		Log.i("AS Service","Sent a local broardcast with the activity data.");

	}
	Log.i("AS", "onHandleIntent called");
}
 
开发者ID:simongray,项目名称:Rejsekort-Reminder,代码行数:30,代码来源:ActivitySensorIntentService.java


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