Hello everyone. I'm implementing app indexing in my android app and I think 
I'm missing something, but I don't know what.

Following the guide (
https://developers.google.com/app-indexing/android/app?utm_source=wnc_546902&utm_medium=gamma&utm_campaign=wnc_546902&utm_content=msg_731912&hl=en)
 
I added my intent-filters to the app and implemented what's needed in my 
activity.

my application's package is com.towers.hotelsclick and the associated 
website (where I didn't put the link rel meta-tag yet, since I'm just 
testing) is www.hotelsclick.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:

<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="hotelsclick.com" />
<data android:scheme="http"
android:host="hotelsclick.com" />
</intent-filter>

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

<provider
android:name=".contentproviders.HotelDetailsContentProvider"
android:authorities="com.towers.hotelsclick" >
</provider>
which should map the URIs as follows:

private static final String BASE_PATH = "https";
private static final String AUTHORITY = "com.towers.hotelsclick";

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://hotelsclick.com?hotel_id=135738 
<https://hotelsclick.com/?hotel_id=135738>" com.towers.hotelsclick
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 
and not hotels)

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://hotelsclick.com?hotel_id=135738 
<http://hotelsclick.com/?hotel_id=135738> are referred as "deep links" 
while those like android-app://com.towers.hotelsclick/https/
hotelsclick.com?hotel_id=135738 <http://hotelsclick.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.

Thank you everybody

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/f6a16ffd-2a1c-43c5-928c-b92fbeec2e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to