To Have Autocomplete Feature Of App Indexing Is It Necessary To Publish Latest Updated App In App Store?
Solution 1:
In the manifest, the activity that needs to be deeplinked(openable by a URI defined by you) should have the following structure :
<activityandroid:name=".MyActivity"
<intent-filterandroid:label="@string/app_name"><actionandroid:name="android.intent.action.VIEW" /><categoryandroid:name="android.intent.category.DEFAULT" /><categoryandroid:name="android.intent.category.BROWSABLE" /><!-- Accepts URIs that begin with "http://my-app.com/mypage" --><dataandroid:scheme="http"android:host="my-app.com"android:pathPrefix="/mypage" /></intent-filter></activity>
In your activity, define a URI which uniquely identifies that activity.
It should be in the following format : //android-app://<package_name>/<scheme>/[host_path])
.
For example :
privatestaticfinalUriMY_URI= Uri.parse("android-app://com.myapp/http/my-app.com/mypage/");
Also, you'll need to use an instance of the GoogleApiClient.
private GoogleApiClient mClient;
In the onCreate function, initialize the client :
mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.APP_INDEX_API).build();
Then, wherever appropriate in the code, connect to the client and create an Action which will be passed to the AppIndex API.
For example :
// Connect your client
mClient.connect();
// Define a title for your current page, shown in autocompletion UIfinalStringTITLE="My Title";
//Define an actionActionviewAction= Action.newAction(Action.TYPE_VIEW, TITLE, MY_URI);
// Call the App Indexing API view method
PendingResult<Status> result = AppIndex.AppIndexApi.start(mClient, viewAction);
result.setResultCallback(newResultCallback<Status>() {
@OverridepublicvoidonResult(Status status) {
if (status.isSuccess()) {
Log.d(TAG, "App Indexing API: Recorded view successfully.");
} else {
Log.e(TAG, "App Indexing API: There was an error recording the view."
+ status.toString());
}
}
});
Finally, disconnect the GoogleApiClient instance in the onStop Method :
mClient.disconnect();
I would suggest that you go through the following tutorial on Google CodeLabs for AppIndexing and DeepLinking. You would require some understanding of how deep linking works before you can implement app indexing properly.
https://codelabs.developers.google.com/codelabs/app-indexing/#0
Post a Comment for "To Have Autocomplete Feature Of App Indexing Is It Necessary To Publish Latest Updated App In App Store?"