这是我的代码请看一下,我应该使用bundle还是创建一个对象来获取值。
public class ActivityReconitionServer extends IntentService {
public ActivityReconitionServer() {
super("ActivityRecognizedService");
}
public ActivityReconitionServer(String name) {
super(name);
}
@Override
protected void onHandleIntent(Intent intent) {
if(ActivityRecognitionResult.hasResult(intent)) {
ActivityRecognitionResult result = ActivityRecognitionResult.extractResult(intent);
handleDetectedActivities( result.getProbableActivities() );
}
}
请看一下.12315468979
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() );
if( activity.getConfidence() >= 75 ) {
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentText( "Are you walking?" );
builder.setSmallIcon( R.mipmap.ic_launcher );
builder.setContentTitle( getString( R.string.app_name ) );
NotificationManagerCompat.from(this).notify(0, builder.build());
}
break;
}
case DetectedActivity.UNKNOWN: {
Log.e( "ActivityRecogition", "Unknown: " + activity.getConfidence() );
break;
}
}
}
}
}
我应该创建一个对象来获取价值还是使用bundle来获取价值?请给我一些建议