diff --git a/docs/html/training/app-indexing/deep-linking.jd b/docs/html/training/app-indexing/deep-linking.jd new file mode 100644 index 0000000000000..a52ae95b80116 --- /dev/null +++ b/docs/html/training/app-indexing/deep-linking.jd @@ -0,0 +1,134 @@ +page.title=Enabling Deep Links for App Content +trainingnavtop=true + +@jd:body + + +
To enable Google to crawl your app content and allow users to enter your app + from search results, you must add intent filters for the relevant + activities in your app manifest. These intent filters allow + deep linking to the content in any of your activities. For example, the user might click on a deep link to view a page within a shopping app that describes a product offering that the user is searching for.
+ +To create a deep link to your app content, add an intent filter that + contains these elements and attribute values in your manifest:
+You can add additional attributes to further refine the type of URI that the activity accepts. For example, you might have multiple activities that accept similar URIs, but which differ simply based on the path name. In this case, use the {@code android:path} attribute or its variants ({@code pathPattern} or {@code pathPrefix}) to differentiate which activity the system should open for different URI paths.
The following XML snippet shows how you might specify an intent filter +in your manifest for deep linking. The URIs {@code “example://gizmos”} and +{@code “http://www.example.com/gizmos”} both resolve to this activity.
+ ++<activity + android:name="com.example.android.GizmosActivity" + android:label="@string/title_gizmos" > + <intent-filter android:label="@string/filter_title_viewgizmos"> + <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 "example://gizmos” --> + <data android:scheme="example" + android:host="gizmos" /> + <!-- Accepts URIs that begin with "http://www.example.com/gizmos” --> + <data android:scheme="http" + android:host="www.example.com" + android:pathPrefix="gizmos" /> + </intent-filter> +</activity> ++ +
Once you've added intent filters with URIs for activity content to your app +manifest, Android is able to route any {@link android.content.Intent} +that has matching URIs to your app at runtime.
+ +To learn more about defining intent filters, see Allow Other Apps to Start Your Activity.
+ +Once the system starts your activity through an intent filter, you can + use data provided by the {@link android.content.Intent} to determine what you need to render. Call the {@link android.content.Intent#getData()} and +{@link android.content.Intent#getAction()} methods to retrieve the data and +action associated with the incoming {@link android.content.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 {@link +android.app.Activity#onCreate(android.os.Bundle) onCreate()} or +{@link android.app.Activity#onStart()}.
+Here’s a snippet that shows how to retrieve data from an +{@link android.content.Intent}:
+
+@Override
+public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ Intent intent = getIntent();
+ String action = intent.getAction();
+ Uri data = intent.getData();
+}
+
+Follow these best practices to improve the user's experience:
+You can use the Android Debug +Bridge with the activity manager (am) tool to test that the intent filter +URIs you specified for deep linking resolve to the correct app activity. You +can run the adb command against a device or an emulator.
+The general syntax for testing an intent filter URI with adb is:
++$ adb shell am start + -W -a android.intent.action.VIEW + -d <URI> <PACKAGE> ++
For example, the command below tries to view a target app activity that +is associated with the specified URI.
++$ adb shell am start + -W -a android.intent.action.VIEW + -d "example://gizmos" com.example.android +diff --git a/docs/html/training/app-indexing/enabling-app-indexing.jd b/docs/html/training/app-indexing/enabling-app-indexing.jd new file mode 100644 index 0000000000000..1636bbc7ff1ee --- /dev/null +++ b/docs/html/training/app-indexing/enabling-app-indexing.jd @@ -0,0 +1,115 @@ +page.title=Specifying App Content for Indexing +trainingnavtop=true + +@jd:body + + +
Google's web crawling bot (Googlebot), which crawls and indexes web sites +for the Google search engine, can also index content in your Android app. +By opting in, you can allow Googlebot to crawl the content in the APK +through the Google Play Store to index the app content. To indicate which app +content you’d like Google to index, simply add link elements either to +your existing Sitemap file or in the {@code <head>} element of each web +page in your site, in the same way as you would for web pages.
+Note: +Currently, the Google Search app indexing capability is restricted to +English-only Android apps from developers participating in the early adopter +program. You can sign up to be a participant by submitting the App Indexing Expression of Interest form. +
+ +The deep links that you share with Google Search must take this URI +format:
++android-app://<package_name>/<scheme>/<host_path> ++
The components that make up the URI format are:
+The following sections describe how to add a deep link URI to your Sitemap +or web pages.
+To annotate the deep link for Google Search app indexing in your +Sitemap, use the +{@code <xhtml:link>} tag and specify the deep link as an alternate URI.
+For example, the following XML snippet shows how you might specify a link to +your web page by using the {@code <loc>} tag, and a corresponding deep +link to your Android app by using the {@code <xhtml:link>} tag.
++<?xml version="1.0" encoding="UTF-8" ?> +<urlset + xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" + xmlns:xhtml="http://www.w3.org/1999/xhtml"> + <url> + <loc>example://gizmos</loc> + <xhtml:link + rel="alternate" + href="android-app://com.example.android/example/gizmos" /> + </url> + ... +</urlset> ++
Instead of specifying the deep links for Google Search app indexing in your +Sitemap file, you can annotate the deep links in the HTML markup of your web +pages. You can do this in the {@code <head>} section for each web +page by adding a {@code <link>} tag and specifying the deep link as an +alternate URI.
+For example, the following HTML snippet shows how you might specify the +corresponding deep link in a web page that has the URL +{@code example://gizmos}.
++<html> +<head> + <link rel="alternate" + href="android-app://com.example.android/example/gizmos" /> + ... +</head> +<body> ... </body> ++ +
Typically, you control how Googlebot crawls publicly accessible URLs on + your site by using a {@code robots.txt} +file. When Googlebot indexes your app content, your app might make HTTP +requests as part of its normal operations. However, these requests will +appear to your servers as originating from Googlebot. Therefore, you must +configure your server's {@code robots.txt} file properly to allow these +requests.
+For example, the following {@code robots.txt} directive shows how you might +allow access to a specific directory in your web site (for example, +{@code /api/}) that your app needs to access, while restricting Googlebot's +access to other parts of your site.
++User-Agent: Googlebot +Allow: /api/ +Disallow: / ++
To learn more about how to modify {@code robots.txt} to control web +crawling, see the Controlling Crawling +and Indexing Getting Started guide.
diff --git a/docs/html/training/app-indexing/index.jd b/docs/html/training/app-indexing/index.jd new file mode 100644 index 0000000000000..6965ce56f0b73 --- /dev/null +++ b/docs/html/training/app-indexing/index.jd @@ -0,0 +1,89 @@ +page.title=Making Your App Searchable +page.tags="app indexing" + +trainingnavtop=true +startpage=true + +@jd:body + +DevBytes: App Indexing
+As mobile apps become more pervasive, users are looking for relevant +information not only from web sites but also from apps they have installed. +You can enable Google to crawl through your app content and present your +Android app as a destination to users through Google Search results, when +that content corresponds to a web page that you own.
+ +You can make it possible for Google Search to open specific content in your + app by providing intent filters for your activities. Google Search +app indexing complements this capability by presenting links to relevant app +content alongside links to your web pages in users' search results. Users on +mobile devices can then click on a link to open your app from their search +results, allowing them to directly view your app's content instead of a +web page.
+ +To enable Google Search app indexing, you need to provide Google with +information about the relationship between your app and web site. This process +involves the following steps:
+Note: +Currently, the Google Search app indexing capability is restricted to +English-only Android apps from developers participating in the early adopter +program. You can sign up to be a participant by submitting the App Indexing Expression of Interest form. +
+ +This class shows how to enable deep linking and indexing of your application +content so that users can open this content directly from mobile search +results.
+ +