To have Autocomplete feature of app indexing is it necessary to publish latest updated app in app store?

雨燕双飞 提交于 2019-12-24 15:36:40

问题


I have added features of App indexing and deep linking for my Game app as a plugin .. deep linking is working properly , the feature of app indexing i.e Autocomplete is not working,.. as ,

PendingResult<Status> result=AppIndex.AppIndexApi.end(mClient,getAction());

result.setResultCallback(new ResultCallback<Status>()

Above Code: Call back records of the visited page;

And shows in play store whenever trying to search similar to the page.

But it is not showing me Autocomplete ..


回答1:


In the manifest, the activity that needs to be deeplinked(openable by a URI defined by you) should have the following structure :

<activity
                android:name=".MyActivity"
                <intent-filter android:label="@string/app_name">
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <!-- Accepts URIs that begin with "http://my-app.com/mypage" -->
                    <data android: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 :

private static final Uri MY_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 UI
final String TITLE = "My Title";
//Define an action
Action viewAction = 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(new ResultCallback<Status>() {
                @Override
                public void onResult(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



来源:https://stackoverflow.com/questions/36930829/to-have-autocomplete-feature-of-app-indexing-is-it-necessary-to-publish-latest-u

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!