Support HTTP URLs in your App

When your app supports HTTP URLs, our systems can use them in Google Search results. Adding support for HTTP URLs involves three basic steps:

  1. Add intent filters for HTTP URLs.
  2. Add logic in your app to handle the intent filters.
  3. Associate your app to your site using Search Console (or Google Play).
Optionally, you can control which parts of your app get indexed by Google systems by using a noindex.xml file.

Add intent filters for HTTP URLs

Intent filters declare the HTTP URL patterns that your app handles from inbound links. These URLs can be the same URLs used for the corresponding pages to your website.

The following code snippet shows an intent handler for links to http://www.examplepetstore.com and https://www.examplepetstore.com:

<activity
  android:name="com.example.android.PetstoreActivity"
 android:label="@string/title_petstore">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" />
        <data android:scheme="https" />
        <data android:host="www.examplepetstore.com" />
    </intent-filter>
</activity>

Use the Android Studio Deep Link Creation feature to quickly generate intent filters for deep links from Search.

Add logic to handle intent filters

Once the system starts the app activity through an intent filter, use the data provided by the Intent to determine your app's view response. Call the getData() and getAction() methods to retrieve the data and action associated with the incoming intent. You can call these methods at any time during the lifecycle of the activity, but you should generally do so during early callbacks such as onCreate() or onStart().

The following example passes the incoming intent to a helper method onNewIntent() in onCreate():

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_recipes);

    onNewIntent(getIntent());
}

Here, the onNewIntent() method verifies the deep link format and displays the page content:

protected void onNewIntent(Intent intent) {
    String action = intent.getAction();
    String data = intent.getDataString();
    if (Intent.ACTION_VIEW.equals(action) && data != null) {
        String recipeId = data.substring(data.lastIndexOf("/") + 1);
        Uri contentUri = PetstoreContentProvider.CONTENT_URI.buildUpon()
                .appendPath(itemID).build();
        showItem(contentUri);
    }
}

Declare a website association

You can make the association between your app and your site from either the Search Console or Google Play. In either case, you must be a verified owner of the app in Google Play and use the same Google account when managing the app in Search Console. Once you make the association, use Fetch as Google to see how your app appears to our systems.

  • From Search Console: Add and verify your app to Search Console (see Search Console for Apps for instructions). Go to Associate a Website, choose your verified app from the list, and enter the URL of the site or sites you want to associate with the app.
  • From the Developer Console: Request to verify your website. This sends a message to your webmaster to associate your app to your site. See App Indexing on Google Search on the Developer Console Help Center for details.

After you make the association, Google automatically starts indexing any existing or new URLs to your app. Our systems use URLs discovered through web indexing that match the intent-filter patterns in your AndroidManifest.xml file. Search Console reports any app URL errors from crawling your app, and you can use its simple debugging workflow in to troubleshoot them.

Note: If you have an app without corresponding web-page content, and you'd like it discovered by Google Search, fill out our app-only interest form. This is currently being tested with a few developers.

Control Indexing (optional)

You can control which app elements appear in the Google index. Specifically, you can adjust the following:

  • Exclude specific pages from Search results

    For first-time App Indexing use, you can configure your manifest to include only those pages you want indexed by Google. Otherwise, create a noindex.xml file to specify the URLs you want excluded from the Google index. This is similar to how the robots noindex meta tag works for websites.

  • Exclude real-time app notifications from Search results

    Use a noindex.xml file with a specific exclude tag for app notifications.

Create the noindex.xml file

Create a new XML file in your app's XML resources directory: res/xml/noindex.xml. It should use statements with specific attributes to indicate those parts of your app to exclude from the Google index. These attributes are as follows:

  1. uri—Indicates a specific URI to exclude from the Google index. Google will not index those URLs that exactly match this attribute.
  2. uriPrefix—Indicates all content beneath a URI path to exclude from the index. Google will not index those URLs that start with the string matching this attribute.
  3. android:value=”notification”—Excludes notifications from your app from the Google Index. Google will not index the notificatios of the app if this attribute is specified.

The following example shows a noindex.xml file that excludes a specific page, hidden directories, and limits app notifications from appearing in Search:

<?xml version="1.0" encoding="utf-8"?>
<search-engine xmlns:android="http://schemas.android.com/apk/res/android">
  <noindex android:value="notification"/>
  <noindex uri="http://examplepetstore.com/dogs/hidden-page"/>
  <noindex uriPrefix="http://examplepetstore.com/cats/hidden_prefix"/>
</search-engine>

Reference the noindex.xml file

After you add the noindex.xml file, reference it from the application section of the app’s AndroidManifest.xml file with the following line:

<meta-data android:name="search-engine" android:resource="@xml/noindex"/>

For example:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.Petstore">
  <application>
    <activity android:name="com.example.android.PetstoreActivity" ...>
      ...
    </activity>
    <meta-data android:name="search-engine" android:resource="@xml/noindex"/>
  </application>
       ...
</manifest>

Next: Add the App Indexing API

Send feedback about...

App Indexing
App Indexing