本文整理汇总了Java中com.google.android.gms.fitness.FitnessStatusCodes类的典型用法代码示例。如果您正苦于以下问题:Java FitnessStatusCodes类的具体用法?Java FitnessStatusCodes怎么用?Java FitnessStatusCodes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FitnessStatusCodes类属于com.google.android.gms.fitness包,在下文中一共展示了FitnessStatusCodes类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: subscribeToSteps
import com.google.android.gms.fitness.FitnessStatusCodes; //导入依赖的package包/类
/**
* Subscribe to an available {@link DataType}. Subscriptions can exist across application
* instances (so data is recorded even after the application closes down). When creating
* a new subscription, it may already exist from a previous invocation of this app. If
* the subscription already exists, the method is a no-op. However, you can check this with
* a special success code.
*/
private void subscribeToSteps() {
Fitness.RecordingApi.subscribe(googleApiClient, DataType.TYPE_STEP_COUNT_DELTA)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
if (status.getStatusCode()
== FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) {
Log.i(TAG, "Existing subscription for activity detected.");
} else {
Log.i(TAG, "Successfully subscribed!");
}
} else {
Log.i(TAG, "There was a problem subscribing.");
}
}
});
}
示例2: onResult
import com.google.android.gms.fitness.FitnessStatusCodes; //导入依赖的package包/类
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
if (status.getStatusCode()
== FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) {
log("Existing subscription detected.");
} else {
log("Successfully set fitness API!");
}
} else {
if (status.getStatusMessage()!=null) {
error( status.getStatusMessage());
} else {
error("subscribe to fit api failed");
}
}
}
示例3: subscribe
import com.google.android.gms.fitness.FitnessStatusCodes; //导入依赖的package包/类
public void subscribe(DataType dataType) {
Fitness.RecordingApi.subscribe(client, dataType)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
if (status.getStatusCode() == FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) {
display.show("Existing subscription for activity detected.");
} else {
display.show("Successfully subscribed!");
}
} else {
display.show("There was a problem subscribing.");
}
}
});
}
示例4: onConnectionFailed
import com.google.android.gms.fitness.FitnessStatusCodes; //导入依赖的package包/类
@Override
public void onConnectionFailed(ConnectionResult result) {
// Error while connecting. Try to resolve using the pending intent returned.
if (result.getErrorCode() == ConnectionResult.SIGN_IN_REQUIRED ||
result.getErrorCode() == FitnessStatusCodes.NEEDS_OAUTH_PERMISSIONS) {
try {
// Request authentication
result.startResolutionForResult(this, REQUEST_OAUTH);
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Exception connecting to the fitness service", e);
}
} else {
Log.e(TAG, "Unknown connection issue. Code = " + result.getErrorCode());
}
}
示例5: onRecordingSubscription
import com.google.android.gms.fitness.FitnessStatusCodes; //导入依赖的package包/类
private void onRecordingSubscription(Status status) {
if (status.isSuccess()) {
if (status.getStatusCode()
== FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) {
Utils.logDebug(TAG, "Existing subscription for activity detected.");
} else {
Utils.logDebug(TAG, "Started recording data for " + mDataType);
}
} else {
// For a better user experience, you can add visual error text indicating the session
// will not be recorded to the cloud.
Utils.logDebug(TAG, "Unable to start recording data for " + mDataType);
}
}