ArchiveDetails: Archive details.
summaryUpdate: Archive summary update data.
isSupportCache: Indicates whether to support cache data.
Google API | To HMS API |
|---|---|
commitAndClose(Snapshot snapshot,SnapshotMetadataChange metadataChange) | addArchive(ArchiveDetails details,ArchiveSummaryUpdate update,boolean isSupportCache) |
The To HMS API method reference is as follows:
boolean isSupportCache = false;// Set this parameter.
ArchivesClient archivesClient = Games.getArchiveClient(this);
ArchiveSummaryUpdate archiveSummaryUpdate = null;// Obtain the value in advance.
ArchiveDetails archiveDetails = new ArchiveDetails.Builder().build();
Task<ArchiveSummary> task = archivesClient.addArchive(archiveDetails, archiveSummaryUpdate, isSupportCache);
task.addOnSuccessListener(new OnSuccessListener<ArchiveSummary>() {
@Override
public void onSuccess(ArchiveSummary archiveSummary) {
if (archiveSummary != null) {
String content = "archiveId:" + archiveSummary.getId();
Log.i("Archive", content);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
String content = "add result:" + apiException.getStatusCode();
Log.e("Archive", content);
}
}); Google API | To HMS API |
|---|---|
delete(GoogleApiClient apiClient, SnapshotMetadata metadata) | removeArchive(ArchiveSummary summary) |
The To HMS API method reference is as follows:
ArchiveSummary archiveSummary = null;// Obtain the value in advance.
ArchivesClient client = Games.getArchiveClient(this);
Task<String> task = client.removeArchive(archiveSummary);
task.addOnSuccessListener(new OnSuccessListener<String>() {
@Override
public void onSuccess(String s) {
Log.i("Archive", "delete success, archiveId:" + s);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
ApiException apiException = (ApiException) e;
Log.e("Archive", "delete failed, statusCode:" + apiException.getStatusCode());
}
}
}); Google API | To HMS API |
|---|---|
Intent getAchievementsIntent(GoogleApiClient apiClient) | Task<Intent> getShowAchievementListIntent() |
The To HMS API method reference is as follows:
AchievementsClient client = Games.getAchievementsClient(this);
Task<Intent> task = client.getShowAchievementListIntent();
task.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
if (intent == null) {
Log.w("Achievement", "intent = null");
} else {
try {
startActivityForResult(intent, 1000);
} catch (Exception e) {
Log.e("Achievement", "Achievement Activity is Invalid");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
String getCurrentPlayerId(GoogleApiClient apiClient) | Task<String> getCachePlayerId() |
The To HMS API method reference is as follows:
PlayersClient client = Games.getPlayersClient(this);
Task<String> task = client.getCachePlayerId();
task.addOnSuccessListener(new OnSuccessListener<String>() {
@Override
public void onSuccess(String playerId) {
Log.i("Player", playerId);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Player", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
PlayerLevelInfo getLevelInfo() | int getLevel() |
The To HMS API method reference is as follows:
int playerLevel = player.getLevel();
Google API | To HMS API |
|---|---|
int getMaxCoverImageSize(GoogleApiClient apiClient, String id) | Task<Integer> getLimitThumbnailSize() |
The To HMS API method reference is as follows:
Task<Integer> task = Games.getArchiveClient(this).getLimitThumbnailSize();
task.addOnSuccessListener(new OnSuccessListener<Integer>() {
@Override
public void onSuccess(Integer integer) {
Log.i("Archive", "Limit thumbnail size:" + integer);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
String result = "MaxData rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Archive", "get Limit thumbnail failed:" + result);
}
}); Google API | To HMS API |
|---|---|
int getMaxDataSize(GoogleApiClient apiClient, String id) | Task<Integer> getLimitDetailsSize() |
The To HMS API method reference is as follows:
Task<Integer> task = Games.getArchiveClient(this).getLimitDetailsSize();
task.addOnSuccessListener(new OnSuccessListener<Integer>() {
@Override
public void onSuccess(Integer integer) {
Log.i("Archive", "Limit details:" + integer);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
String result = "MaxData rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Archive", "get Limit details failed:" + result);
}
}); Google API | To HMS API |
|---|---|
Intent getSelectSnapshotIntent(GoogleApiClient,String title, boolean allowAddButton, boolean allowDeleteBtn, int maxArchive) | Task<Intent> getShowArchiveListIntent(String title, boolean allowAddButton, boolean allowDeleteBtn, int maxArchive) |
The To HMS API method reference is as follows:
String title = "title";// Set this parameter.
boolean allowAddBtn = true;// Set this parameter.
boolean allowDeleteBtn = true;// Set this parameter.
int maxArchive = 1;// Set this parameter.
Task<Intent> task = Games.getArchiveClient(this).getShowArchiveListIntent(title, allowAddBtn, allowDeleteBtn, maxArchive);
task.addOnSuccessListener(new OnSuccessListener<Intent>() {
@Override
public void onSuccess(Intent intent) {
if (intent == null) {
Log.w("Archive", "intent = null");
} else {
try {
startActivityForResult(intent, 2000);
} catch (Exception e) {
Log.e("Archive", "Archive Activity is Invalid");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Archive", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
getSnapshotFromBundle(Bundle bundle) | parseSummary(Bundle bundle) |
The To HMS API method reference is as follows:
Bundle bundle = new Bundle();// Set the value in advance.
ArchivesClient client = Games.getArchiveClient(this);
Task<ArchiveSummary> task = client.parseSummary(bundle);
task.addOnSuccessListener(new OnSuccessListener<ArchiveSummary>() {
@Override
public void onSuccess(ArchiveSummary archiveSummary) {
if (archiveSummary != null) {
Log.i("Archive", "FileName:" + archiveSummary.getFileName());
Log.i("Archive", "Id:" + archiveSummary.getId());
Log.i("Archive", "DescInfo:" + archiveSummary.getDescInfo());
Log.i("Archive", "UpdateTime:" + archiveSummary.getRecentUpdateTime());
Log.i("Archive", "ActiveTime:" + archiveSummary.getActiveTime());
Log.i("Archive", "ThumbnailRatio:" + archiveSummary.getThumbnailRatio());
Log.i("Archive", "currentProgress:" + archiveSummary.getCurrentProgress());
Log.i("Archive", "ThumbnailUri:" + archiveSummary.hasThumbnail());
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Archive", result);
}
}
}); Google API | To HMS API |
|---|---|
incrementImmediate(GoogleApiClient apiClient, String id, int numSteps) | growWithResult(String id, int numSteps) |
The To HMS API method reference is as follows:
String id = "id";// Set this parameter.
int steps = 1;// Set this parameter.
AchievementsClient client = Games.getAchievementsClient(this);
Task<Boolean> task = client.growWithResult(id, steps);
task.addOnSuccessListener(new OnSuccessListener<Boolean>() {
@Override
public void onSuccess(Boolean isSucess) {
if (isSucess) {
Log.i("Achievement", "grow success");
} else {
Log.i("Achievement", "achievement can not grow");
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", result);
}
}
}); Google API | To HMS API |
|---|---|
loadByIds(GoogleApiClient apiClient, boolean forceReload, String... eventIds) | getEventListByIds(boolean forceReload,String[] eventIds) |
The To HMS API method reference is as follows:
boolean forceReload = true;// Set this parameter.
String[] eventIds = null;// Set this parameter.
EventsClient client = Games.getEventsClient(this);
Task<List<Event>> task = client.getEventListByIds(forceReload, eventIds);
task.addOnSuccessListener(new OnSuccessListener<List<Event>>() {
@Override
public void onSuccess(List<Event> data) {
Iterator<Event> iterator = data.iterator();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Event", result);
}
}
}); Google API | To HMS API |
|---|---|
loadMoreScores(LeaderboardScoreBuffer buffer, int maxResults, int pageDirection) | getMoreRankingScores(String rankingId, long offsetPlayerRank,int maxResults, int pageDirection, int timeDimension) |
The To HMS API method reference is as follows:
RankingsClient client = Games.getRankingsClient(this);
Task<RankingsClient.RankingScores> task = client.getMoreRankingScores("rankingId", 1, 20, 1, 2);
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e("Ranking", "failure. exception: " + e);
}
});
task.addOnSuccessListener(new OnSuccessListener<RankingsClient.RankingScores>() {
@Override
public void onSuccess(RankingsClient.RankingScores s) {
Log.i("Ranking", " success. ");
}
}); Google API | To HMS API |
|---|---|
loadPlayerCenteredScores(String leaderboardId, int span, int leaderboardCollection, int maxResults) | getPlayerCenteredRankingScores(String rankingId, int timeDimension,int maxResults, long offsetPlayerRank, int pageDirection) |
The To HMS API method reference is as follows:
RankingsClient client = Games.getRankingsClient(this);
Task<RankingsClient.RankingScores> task = client.getPlayerCenteredRankingScores("rankingId", 1, 20, 1, 1);
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e("Ranking", " failure. exception: " + e);
}
});
task.addOnSuccessListener(new OnSuccessListener<RankingsClient.RankingScores>() {
@Override
public void onSuccess(RankingsClient.RankingScores s) {
Log.i("Ranking", " success");
}
}); forceReload: Indicates whether to obtain online data or cache data (online: true; offline: false).
Google API | To HMS API |
|---|---|
loadPlayerStats(GoogleApiClient apiClient, boolean forceReload) | getGamePlayerStatistics(boolean forceReload) |
The To HMS API method reference is as follows:
GamePlayerStatisticsClient playerStatsClient = Games.getGamePlayerStatsClient(this);
// Indicates whether to obtain data from the server.
boolean isRealTime = false;
Task<GamePlayerStatistics> task = playerStatsClient.getGamePlayerStatistics(isRealTime);
task.addOnSuccessListener(new OnSuccessListener<GamePlayerStatistics>() {
@Override
public void onSuccess(GamePlayerStatistics playerStats) {
StringBuilder sb = new StringBuilder();
sb.append("AverageOnlineMinutes: " + playerStats.getAverageOnLineMinutes());
sb.append("DaysFromLastGame: " + playerStats.getDaysFromLastGame());
sb.append("PaymentTimes: " + playerStats.getPaymentTimes());
sb.append("OnlineTimes: " + playerStats.getOnlineTimes());
sb.append("TotalPurchasesAmountRange: " + playerStats.getTotalPurchasesAmountRange());
Log.i("Ranking", "Result:" + sb.toString());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Ranking", result);
}
}
}); isRealTime: Indicates whether to obtain online data or cache data (online: true; offline: false).
Google API | To HMS API |
|---|---|
loadTopScores(String leaderboardId, int span, int leaderboardCollection, int maxResults) | getRankingTopScores(String rankingId, int demension, int maxResults, boolean isRealTime) |
The To HMS API method reference is as follows:
String rankingId = "rankingId";// Set this parameter.
RankingsClient client = Games.getRankingsClient(this);
Task<RankingsClient.RankingScores> task = client.getRankingTopScores(rankingId, 20, 1, true);
task.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e("Ranking", " failure. exception: " + e);
}
});
task.addOnSuccessListener(new OnSuccessListener<RankingsClient.RankingScores>() {
@Override
public void onSuccess(RankingsClient.RankingScores s) {
Log.i("Ranking", " success. ");
}
}); Google API | To HMS API |
|---|---|
open(GoogleApiClient apiClient, SnapshotMetadata metadata) | loadArchiveDetails(ArchiveSummary archiveSummary) |
The To HMS API method reference is as follows:
String summary = "summary";// Set this parameter.
ArchiveSummary archiveSummary = null;// Obtain the value in advance.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task = client.loadArchiveDetails(summary);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", "loadArchiveDetails success");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.i("Archive", "loadArchiveDetails failed");
}
}); Google API | To HMS API |
|---|---|
open(GoogleApiClient apiClient, SnapshotMetadata metadata, int conflictPolicy) | loadArchiveDetails(String archiveId, int strategy) |
The To HMS API method reference is as follows:
String archiveId = "archiveId";// Set this parameter.
int conflictPolicy = 1;// Set this parameter.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task = client.loadArchiveDetails(archiveId, conflictPolicy);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", "loadArchiveDetails success");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.i("Archive", "loadArchiveDetails failed");
}
}); Google API | To HMS API |
|---|---|
open(GoogleApiClient apiClient, String fileName, boolean createIfNotFound) | loadArchiveDetails(String archiveId) |
The To HMS API method reference is as follows:
String archiveId = "archiveId";// Set this parameter.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task = client.loadArchiveDetails(archiveId);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", "loadArchiveDetails success");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.e("Archive", "loadArchiveDetails failed");
}
}); Google API | To HMS API |
|---|---|
open(GoogleApiClient apiClient, String fileName, boolean createIfNotFound, int conflictPolicy) | loadArchiveDetails(String archiveId, int diffStrategy) |
The To HMS API method reference is as follows:
String archiveId = "archiveId";// Set this parameter.
int conflictPolicy = 1;// Set this parameter.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task = client.loadArchiveDetails(archiveId, conflictPolicy);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", "loadArchiveDetails success");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.i("Archive", "loadArchiveDetails failed");
}
}); isRealTime: Indicates whether to obtain online data or cache data (online: true; offline: false).
Google API | To HMS API |
|---|---|
load(GoogleApiClient apiClient, boolean forceReload) | getAchievementList(boolean forceReload) |
The To HMS API method reference is as follows:
AchievementsClient client = Games.getAchievementsClient(this);
boolean forceReload = true;// Set this parameter.
Task<List<Achievement>> task = client.getAchievementList(forceReload);
task.addOnSuccessListener(new OnSuccessListener<List<Achievement>>() {
@Override
public void onSuccess(List<Achievement> data) {
if (data == null) {
return;
}
Iterator<Achievement> iterator = data.iterator();
while (iterator.hasNext()) {
Achievement achievement = iterator.next();
Player player = achievement.getGamePlayer();
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
load(GoogleApiClient apiClient, boolean forceReload) | getEventList(boolean forceReload) |
The To HMS API method reference is as follows:
boolean forceReload = true;// Set this parameter.
EventsClient client = Games.getEventsClient(this);
Task<List<Event>> task = client.getEventList(forceReload);
task.addOnSuccessListener(new OnSuccessListener<List<Event>() {
@Override
public void onSuccess(List<Event> data) {
if (data == null) {
Log.i("Event", "data is null");
return;
}
Iterator<Event> iterator = data.iterator();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Event", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
load(GoogleApiClient apiClient, boolean forceReload) | getArchiveSummaryList(boolean isRealName) |
The To HMS API method reference is as follows:
boolean isRealTime = true;// Set this parameter.
ArchivesClient client = Games.getArchiveClient(this);
Task<List<ArchiveSummary>> task = client.getArchiveSummaryList(isRealTime);
task.addOnSuccessListener(new OnSuccessListener<List<ArchiveSummary>>() {
@Override
public void onSuccess(List<ArchiveSummary> data) {
if (data == null) {
return;
}
Log.i("Archive ", "get archive list success");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Archive", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
Player getCurrentPlayer(GoogleApiClient apiClient) | Task<Player> getCurrentPlayer() |
The To HMS API method reference is as follows:
PlayersClient client = Games.getPlayersClient(this);
Task<Player> task = client.getCurrentPlayer();
task.addOnSuccessListener(new OnSuccessListener<Player>() {
@Override
public void onSuccess(Player player) {
Log.i("Player", player.getDisplayName());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Player", "result:" + result);
}
}
}); Google API | To HMS API |
|---|---|
PlayerStats getPlayerStats() | Task<GamePlayerStatistics> getGamePlayerStatistics(boolean isRealTime) |
The To HMS API method reference is as follows:
boolean isRealTime = true;// Set this parameter.
GamePlayerStatisticsClient playerStatsClient = Games.getGamePlayerStatsClient(this);
Task<GamePlayerStatistics> task = playerStatsClient.getGamePlayerStatistics(isRealTime);
task.addOnSuccessListener(new OnSuccessListener<GamePlayerStatistics>() {
@Override
public void onSuccess(GamePlayerStatistics gamePlayerStatistics) {
if (gamePlayerStatistics == null) {
Log.i("gamePlayerStatistics", "playerStatsAnnotatedData is null, inner error");
return;
}
StringBuilder sb = new StringBuilder();
sb.append("IsRealTime:" + ISREALTIME);
sb.append("\n---AverageSessionLength: " + gamePlayerStatistics.getAverageOnLineMinutes() + "\n---");
sb.append("DaysSinceLastPlayed: " + gamePlayerStatistics.getDaysFromLastGame() + "\n---");
sb.append("NumberOfPurchases: " + gamePlayerStatistics.getPaymentTimes() + "\n---");
sb.append("NumberOfSessions: " + gamePlayerStatistics.getOnlineTimes() + "\n---");
sb.append("TotalPurchasesAmountRange: " + gamePlayerStatistics.getTotalPurchasesAmountRange());
Log.i("gamePlayerStatistics",sb.toString());
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.i("gamePlayerStatistics",result);
}
}
}); Google API | To HMS API |
|---|---|
resolveConflict(GoogleApiClient apiClient, String conflictId, Snapshot snapshot) | updateArchive(Archive archive) |
The method reference is as follows:
Archive archive = null;// Obtain the value in advance.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task =
client.updateArchive(archive);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", "update archive success");
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.e("Archive ", "update result:" + apiException.getStatusCode());
}
}); Google API | To HMS API |
|---|---|
resolveConflict(GoogleApiClient apiClient, String conflictId,String snapshotId, SnapshotMetadataChange metadataChange, SnapshotContents snapshotContents) | updateArchive(String id,ArchiveSummaryUpdate summaryUpdate,ArchiveDetails details) |
The To HMS API method reference is as follows:
String id = "id";// Set this parameter.
ArchiveSummaryUpdate archiveSummaryUpdate = null;// Obtain the value in advance.
ArchiveDetails archiveDetails = null;// Obtain the value in advance.
ArchivesClient client = Games.getArchiveClient(this);
Task<OperationResult> task =
client.updateArchive(id, archiveSummaryUpdate, archiveDetails);
task.addOnSuccessListener(new OnSuccessListener<OperationResult>() {
@Override
public void onSuccess(OperationResult result) {
if (result != null && !result.isDifference()) {
Archive archive = result.getArchive();
if (archive != null && archive.getSummary() != null) {
Log.i("Archive", archive.getSummary().getId());
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ApiException apiException = (ApiException) e;
Log.e("Archive", "update failed");
}
}); Google API | To HMS API |
|---|---|
revealImmediate(GoogleApiClient apiClient, String id) | visualizeWithResult(String id) |
The To HMS API method reference is as follows:
String id = "id";// Set this parameter.
AchievementsClient client = Games.getAchievementsClient(this);
Task<Void> task = client.visualizeWithResult(id);
task.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void v) {
Log.i("Achievement", "visualize success");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", "visualize failed:" + result);
}
}
}); Google API | To HMS API |
|---|---|
setStepsImmediate(GoogleApiClient apiClient,String id, int numSteps) | makeStepsWithResult(String id, int numSteps) |
The To HMS API method reference is as follows:
String achievementId = "id";// Set this parameter.
int numSteps = 1;// Set this parameter.
AchievementsClient client = Games.getAchievementsClient(this);
Task<Boolean> task = client.makeStepsWithResult(achievementId, numSteps);
task.addOnSuccessListener(new OnSuccessListener<Boolean>() {
@Override
public void onSuccess(Boolean isSucess) {
Log.i("Achievement", "make steps result:" + isSucess);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", "make steps failed:" + result);
}
}
}); Google API | To HMS API |
|---|---|
unlockImmediate(GoogleApiClient apiClient, String id) | reachWithResult(String id) |
The To HMS API method reference is as follows:
String achievementId = "id";// Set this parameter.
AchievementsClient client = Games.getAchievementsClient(this);
Task<Void> task = client.reachWithResult(achievementId);
task.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void v) {
Log.i("Achievement", "reach success");
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
if (e instanceof ApiException) {
String result = "rtnCode:" + ((ApiException) e).getStatusCode();
Log.e("Achievement", "reach failed:" + result);
}
}
});