[General Marketing & SEO] ilsecondodasinistra:
I'm implementing app indexing and I think I'm missing something, but I don't know what.

Following the guide I added my intent-filters to the app and implemented what's needed in my activity.

my application's package is com.towers.mypackage and the associated website (where I didn't put the link rel meta-tag yet, since I'm just testing) is www.mypackage.com

I saw the following intent-filter example in the guide

<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>

so I wrote mine in this way:

<activity
android:name=".ActivityForAppIndexing"
android:label="@string/title_activity"
android:screenOrientation="portrait" >
<intent-filter android:label="@string/app_name">
<data android:scheme="android-app"
android:host="com.package.myappname" />
<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="www.mywebsite.com" />
<data android:scheme="https"
android:host="www.mywebsite.com" />
</intent-filter>
</activity>

Also, I wrote a content provider in order to parse the URI

<provider
android:name=".contentproviders.HotelDetailsContentProvider"
android:authorities="com.towers.mypackage" >
</provider>

which should map the URIs as follows:

private static final String BASE_PATH = "https";
private static final String AUTHORITY = "com.towers.mypackage";
public static final Uri CONTENT_URI = Uri.parse("android-app://" + AUTHORITY
+ "/" + BASE_PATH);

I'm testing the implementation via command line using the following adb command:

adb shell am start -a android.intent.action.VIEW -d "https://mypackage.com?hotel_id=135738" com.towers.mypackage

and IT WORKS. The app gets automatically opened with the right activity and the right parameters. When the app starts the onNewIntent method gets called:

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 = HotelDetailsContentProvider.CONTENT_URI.buildUpon()
.appendPath(recipeId).build();
bundle = new Bundle();
bundle.putString("pictureUrl", "");

//showRecipe(contentUri);
}
}

(I got it of course from the examples, that's why it talks about recipes)

But I wonder: what should I do? Get data from the intent with a

getIntent().getData().getQuery()

or use the ContentProvider and get them from the URI?

Also, I'd like to test with the Google Search Console and the "View as google" funcionality if everything is okay. I uploaded my APK and saw an URI is requested.

Now, in the "testing your app" section of the documentation I saw that the links like http://mypackage.com?hotel_id=135738 are referred as "deep links" while those like android-app://com.towers.mypackage/https/mypackage.com?hotel_id=135738 are referred as "URI". Am I right?

The "View as google" funcionality asks for a URI but I don't know how to create one. Also, I wonder how this URI is passed to the app and I'm pretty sure I'm getting very confused about this all URI/deepLink thing, and can't find relief in the documentation.

Where and when should I use the URI? Where and when should I use the deepLink? I guess that since I'm going to put the link rel=URI in my webpages then the app will be called in the app indexing with the URI and not with the URL of the page. But if it's so... why is the adb shell am start -a android.intent.action.VIEW -d command used for testing with the URL and not the URI? Should my app be able to get and handle URIs or URLs? And how?

I thought I had understood something about app indexing, but today I'm starting to think I got it all wrong since I started. That's why I ask you for help in answering the questions above, and possibly sheding a light on all this URL/URI/intent-filter/ContentProvider mess.

I already talked about this on Stackoverflow and got two answers, plus a lot of comments. But I wasn't able to get anything from that, App indexing remains a mysterious monster to me :-/

Did anyone of you manage to make this kind of things work? And how?

Thank you everybody, really.