Example App: Foursquare

Foursquare is a local search and discovery app that provides a rich personalized search experience for users.

Example: Defining Deep Links – Intent Filters

<activity xmlns:android="http://schemas.android.com/apk/res/android"
    android:name="foursquare.HandleURL"
         	android:label="Foursquare">
    <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" android:host="foursquare.com" />
    </intent-filter>
</activity>

Example: Defining Deep Links – Handling the Intent

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Intent intent = getIntent();
    Uri data = intent.getData();
    String path = data.getPath();
    //URL:
    //"https://foursquare.com/explore?near=Mountain%20View&q=Dinner"
    //Path object now is equal to "near=Mountain%20View&q=Dinner"
}

Example: Publishing – Web to Native

<?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>
            https://foursquare.com/explore?near=Mountain+View&q=Dinner
        </loc>
        <xhtml:link rel="alternate"
            href="android-app://foursquare/http/foursquare.com/explore?near=Mountain+View&q=Dinner"/>
        <xhtml:link rel="alternate" type="x-edition/mobile-web"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
        <xhtml:link rel="alternate" type="x-edition/android-4.0"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
        <xhtml:link rel="alternate" type="x-edition/new-winphone"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
    </url>
</urlset>

Example: Publishing – Stand-alone Android

<?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>
        <xhtml:link
            href="android-app://foursquare/http/foursquare.com/explore?near=Mountain+View&q=Dinner" />
        <xhtml:link rel="alternate" type="x-edition/mobile-web"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
        <xhtml:link rel="alternate" type="x-edition/android-4.0"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
        <xhtml:link rel="alternate" type="x-edition/new-winphone"
            href="http://foursquare.com/explore?near=Mountain+View&q=Dinner" />
    </url>
</urlset>