1
Google FitのSensors APIから、ウォッチフェイスサービス(Android Wear)で場所と速度を記録しようとしています。ここで私が使用したコードだ:Google Fitに表示されるデータソースがありません
private void connectFitnessDataListeners() {
Fitness.SensorsApi.findDataSources(mGoogleApiClient,
new DataSourcesRequest.Builder()
.setDataTypes(DataType.TYPE_ACTIVITY_SAMPLE)
.setDataTypes(DataType.TYPE_LOCATION_SAMPLE)
.setDataTypes(DataType.TYPE_SPEED)
// Can specify whether data type is raw or derived.
.setDataSourceTypes(DataSource.TYPE_RAW)
.build())
.setResultCallback(new ResultCallback<DataSourcesResult>() {
@Override
public void onResult(DataSourcesResult dataSourcesResult) {
Log.i(TAG, "Find Data Sources: " + dataSourcesResult.getStatus().toString());
for (DataSource dataSource : dataSourcesResult.getDataSources()) {
//only include dataSources from the watch
Log.i(TAG, "Data source found: " + dataSource.toString());
Log.i(TAG, String.format("Data Source device %s and type: %s", dataSource.getDevice().toString(),dataSource.getDataType().getName()));
if (dataSource.getDevice() != Device.getLocalDevice(getBaseContext())) continue;
//FIXME: Turn this into a loop over an array
if (dataSource.getDataType().equals(DataType.TYPE_ACTIVITY_SAMPLE) && (mActivitySampleListener == null)) {
Log.i(TAG, "Data source for ACTIVITY_SAMPLE found! Registering.");
mActivitySampleListener = registerFitnessDataListener(dataSource, DataType.TYPE_ACTIVITY_SAMPLE);
} else if (dataSource.getDataType().equals(DataType.TYPE_LOCATION_SAMPLE) && (mLocationSampleListener == null)) {
Log.i(TAG, "Data source for LOCATION_SAMPLE found! Registering.");
mLocationSampleListener = registerFitnessDataListener(dataSource, DataType.TYPE_ACTIVITY_SAMPLE);
} else if (dataSource.getDataType().equals(DataType.TYPE_SPEED) && (mSpeedListener == null)) {
Log.i(TAG, "Data source for SPEED found! Registering.");
mSpeedListener = registerFitnessDataListener(dataSource, DataType.TYPE_SPEED);
}
}
}
}
);
}
をしかし、私はそうonConnectedワーキングコールでこれを実行すると、私はループのために何のデータソースを取得していない(Find Data Sources
ログ呼び出しが成功を示しています)。
私は何を追求すべきですか?
UPDATE:私はGPSからの位置情報が表示されていないだから、なぜ
Data source found: DataSource{derived:Application{com.google.android.gms::null}:Device{Sony:SmartWatch 3:15e991d4::3:2}::DataType{com.google.speed[speed(f)]}}
Data Source device Device{Sony:SmartWatch 3:15e991d4::3:2} and type: com.google.speed
: 私はsetDataSourceTypes
制限を削除した場合、私はこれだけを取得しますか?