Академический Документы
Профессиональный Документы
Культура Документы
In this document
Typical Workow
Adding an Intent Filter for
URL Support and Google
Search
Adding App Indexing API
Skeleton Code to an Activity
Testing a URL
Typical Workow
To use Android Studio to add support for URL,
app indexing, and search features to your app:
1. Add intent lters and code to handle
incoming intents.
2. Associate a website with your app.
3. Add App Indexing API code.
See also
App Indexing
logcat Monitor
(https://developers.google.com/app-indexing/reference
/deeplinks)
Video
DevBytes: App Indexing
Dependencies and
prerequisites
instead.
Chrome displaying google.com serves search results with URLs that are accessible
to both signed-in users and those who aren't. Google Search app users must be
signed in to see URLs in their search results.
cant
the App Indexing API. These warnings and errors appear in the Code Editor and
in Lint inspection results.
A Google App Indexing test checks whether Google can index a URL by either
crawling your app page or using the App Indexing API.
The details for implementing URL support and app indexing are described next.
(https://www.jetbrains.com/idea/help/generating-code.html)
mechanisms.
android:scheme="http" //>>
<<//iinntteenntt--ffiilltteerr>>
We recommend that you dene a <data> element that supports URLs that youll
add in the future. In the previous sample code, for example, Google will index
any URLs starting with http://www.example.com/gizmos. Also, remember to
include a URL for your app home screen so its included in search results.
The URLs you specify in your intent lters can be the same as the URLs of the
comparable pages on your website.
4. In the corresponding activity, add Java code (https://developer.android.com/training
/app-indexing/deep-linking.html#handling-intents)
Alternatively, for Android 6.0 (API level 23) and higher, add link default handling
and verication (https://developer.android.com/training/app-links/index.html).
2. Optionally exclude certain URLs (https://developers.google.com/app-indexing/android
/app#create-the-noindexxml-le)
3. Optionally add App Indexing API code (#indexing) to support additional search
features.
To test and debug your links, you can use the following Android Studio features:
Launch your URL (#testintent) in Android Studio to test that it works.
Enable the following Android Lint categories (#lint):
Missing support for Google App Indexing
URL not supported by app for Google App Indexing
Perform a Google App Indexing Test (#appindexingtest).
In addition, you can preview your APK in the Google Search Console
(https://developers.google.com/app-indexing/android/test#preview-your-apk-on-search-console)
to test
appears.
Right-click in an activity denition and select Generate > App Indexing API
Code.
Place the cursor in an activity, and then select Code > Generate > App
Indexing API Code.
The Code Editor adds skeleton code using the intention action
(https://www.jetbrains.com/idea/help/intention-actions.html)
(https://www.jetbrains.com/idea/help/generating-code.html)
mechanisms.
If you dont see the App Indexing API Code menu item, make sure your cursor is
within an activity, and check your code for App Indexing API methods. The Code
Editor can insert skeleton Java code into an activity in the following
circumstances:
The activity doesnt have an onStart() method, or the onStart() method
doesnt contain an AppIndexApi.start() or AppIndexApi.view() call.
The activity doesnt have an onStop() method, or the onStop() method
doesnt contain an AppIndexApi.end() or AppIndexApi.viewEnd() call.
The Code Editor adds Java code similar to the following:
/**
@Override
ppuubblliicc vvooiidd onStart() {
ssuuppeerr.onStart();
@Override
ppuubblliicc vvooiidd onStop() {
ssuuppeerr.onStop();
For more information about the App Indexing API methods, see Android API
for App Indexing (https://developers.google.com/app-indexing/reference/package-summary)
. For
information about the action types, see the Action Class Constant Summary
(https://developers.google.com/android/reference/com/google/android/gms/appindexing
/Action#constant-summary)
If your app isnt already congured for the Google Play Services App Indexing
API, the Code Editor also modies your build.gradle and
AndroidManifest.xml les to include it. If your app already depends on it but
the version is lower than 8.1.0, your app is upgraded to version 8.1.0. For more
information and to correct any issues, see Add Google Play Services
(https://developers.google.com/app-indexing/android/publish#add-google-play-services)
and
4. Verify that your app indexing code is working (#testindexing) by using the logcat
Monitor.
To test and debug your App Indexing API code, you can use the following Android
Studio features:
Examine logcat Monitor Messages (#testindexing).
Enable the following Android Lint category (#lint): Missing support for Google App
Indexing API
Perform a Google App Indexing Test (#appindexingtest).
In addition, you can preview your APK in the Google Search Console
(https://developers.google.com/app-indexing/android/test#preview-your-apk-on-search-console)
Testing a URL
When you run your app from Android Studio, you can specify a URL to launch so you
can test it.
To launch a URL from Android Studio:
You can view App Indexing API log messages while the app is running, as described
next.
page and
Conguring Lint
You can use the Android Studio built-in Lint tool to check whether you have valid
URLs dened in the manifest and have implemented the App Indexing API correctly
in activities.
You can view URL and app indexing warnings and errors in two ways:
As pop-up text in the Code Editor. When Lint nds a problem, it highlights the
problematic code in yellow, or underlines the code in red for more serious
issues.
In the Lint Inspection Results window after you select Analyze > Inspect Code.
To set default Lint checks for URLs and the App Indexing API:
1. In Android Studio, open your project in Android view (https://developer.android.com/studio
/projects/index.html#ProjectFiles).
6. Click OK.
To produce a list of Lint checks displayed in the Inspection Results window:
1. In Android Studio, open your project in Android view (https://developer.android.com/studio
/projects/index.html#ProjectFiles)
test.
2. Select Analyze > Inspect Code.
3. In the Specify Inspection Scope dialog, select the inspection scope and prole.
The scope species the les you want to analyze, and the prole species the
Lint checks youd like to perform.
4. If you want to change the Lint settings, click . In the Inspections dialog,
optionally click Manage to dene a new prole, specify the Lint settings you
If the app preview on the right shows the screen that corresponds to the URL
you're testing, then Googlebot can nd the URL.
6. Correct any issues the test identies, and repeat the test as often as needed.
The following table lists common errors and warnings you might encounter.
Warning or Error
Description
Error: Google
page.
Warning: The App
empty.
using Googlebot
crawling but
identied blocked
resources.
Warning: Google
app.
Indexing API.