Reputation: 434
I am implementing the app indexing API provided by google. As indicated here I connected the client in onStart() method like this:
APP_URI = Uri.parse(baseAppUri + slug);
WEB_URL = Uri.parse(baseWebUri + slug);
Action viewAction = Action.newAction(Action.TYPE_VIEW, title, WEB_URL, APP_URI);
// Call the App Indexing API start method after the view has
// completely
// rendered
// Call the App Indexing API view method
PendingResult<Status> result = AppIndex.AppIndexApi.start(mClient, viewAction);
result.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
CommonLib.ZLog(TAG, "App Indexing API: Recorded " + title + " view successfully.");
} else {
Log.e(TAG, "App Indexing API: There was an error recording the view." + status.toString());
}
}
});
and after the user is done on the page i.e. user presses back button I call AppIndexApi.end in onStop() like this:
@Override
protected void onStop() {
// Call end() and disconnect the client
Action viewAction = Action.newAction(Action.TYPE_VIEW, title, APP_URI);
PendingResult<Status> result = AppIndex.AppIndexApi.end(mClient, viewAction);
result.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
Log.d(TAG, "App Indexing API: Recorded " + title + " view end successfully.");
} else {
Log.e(TAG, "App Indexing API: There was an error recording the view." + status.toString());
}
}
});
mClient.disconnect();
super.onStop();
}
The problem is that the callback is not being executed. None of the cases in resultcallback are logging the status and execution jumps directly to mClient.disconnect.
And the title is not being shown in the search result in google app.
Any idea where I am going wrong here?
Upvotes: 3
Views: 231
Reputation: 1168
Please try and debug your app stepwise. I had the similar issue and debugging help me find out that there was some exception occurring in some other code due to which the callback was not occuring
Upvotes: 0