You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 10, 2022. It is now read-only.
In the app-indexing sample, onStop() has the following code to end the indexing action and log the result:
finalStringTITLE = recipe.getTitle();
finalUriAPP_URI = BASE_APP_URI.buildUpon().appendPath(recipe.getId()).build();
ActionviewAction = Action.newAction(Action.TYPE_VIEW, TITLE, APP_URI);
PendingResult<Status> result = AppIndex.AppIndexApi.end(mClient, viewAction);
result.setResultCallback(newResultCallback<Status>() {
@OverridepublicvoidonResult(Statusstatus) {
if (status.isSuccess()) {
Log.d(TAG, "App Indexing API: Recorded recipe "
+ recipe.getTitle() + " view end successfully.");
} else {
Log.e(TAG, "App Indexing API: There was an error recording the recipe view."
+ status.toString());
}
}
});
mClient.disconnect();
The problem with this is that immediately disconnecting from the client means the ResultCallback will never fire, making it pointless. Either the ResultCallback should be removed from this sample, or the code should wait until the result is received to disconnect, a la:
result.setResultCallback(newResultCallback<Status>() {
@OverridepublicvoidonResult(Statusstatus) {
if (status.isSuccess()) {
Log.d(TAG, "App Indexing API: Recorded recipe "
+ recipe.getTitle() + " view end successfully.");
} else {
Log.e(TAG, "App Indexing API: There was an error recording the recipe view."
+ status.toString());
}
mClient.disconnect();
}
});