Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android-app link not working

I'm following this example from Google I/O 2015.
Demo webite: http://recipe-app.com/recipe/grilled-potato-salad Demo app: http://search-codelabs.appspot.com/codelabs/android-deep-linking

My test:
I've installed the demo app from above link. I did a Google search using Google Search app for "grilled potato salad" and found http://recipe-app.com/recipe/grilled-potato-salad.
I would expect clicking on the link would open the app directly, not the disambiguation dialog (http://search-codelabs.appspot.com/img/android-deep-linking/img-5.png). However, the disambiguation dialog still shows to my surprise.

Isn't the <link rel="alternate" href="android-app://com.recipe_app/http/recipe-app.com/recipe/grilled-potato-salad" /> on the website useless then?

The app's manifest file:
```

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/CustomActionBarTheme" >

    <activity
        android:name=".client.HomeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity
        android:name=".client.RecipeActivity"
        android:label="@string/app_name"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@android:style/Theme.Holo.NoActionBar">
        <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" />
            <!-- Accepts URIs that begin with "http://recipe-app.com/recipe" -->
            <data android:scheme="http"
                android:host="recipe-app.com"
                android:pathPrefix="/recipe" />
        </intent-filter>
    </activity>

    <provider
        android:name=".client.content_provider.RecipeContentProvider"
        android:authorities="com.recipe_app" >
    </provider>
</application>

```

like image 343
ericn Avatar asked Aug 31 '16 03:08

ericn


People also ask

Why link is not opening in-app?

Every android app will have list of urls that it can open. So you have to go to that app settings and tell that it should open in browser for the urls and not in the app. To do that go to Settings -> Apps -> scroll down to the app that you don't want URLs to open in -> Tap on 'Open by Default' and select always Ask.

Why can't I open links on my Android?

Why can't I open links on Android? If you can't open links on Android apps, make sure to check in-app settings, reinstall the app, or inspect in-app permissions. If that doesn't help, clearing cache and data from essential Google Services or reinstalling WebView should resolve the issue.


2 Answers

That tutorial was indeed outdated.
The HTML markup was indeed useless.

What was required for Google search results to work with deep link is to have a publicly reabled https://<yoursite>/.well-known/assetlinks.json file on your production webserver following the instructions here:
After setting up URL support for your app, the App Links Assistant generates a Digital Asset Links file you can use to associate your website with your app.

As an alternative to using the Digital Asset Links file, you can associate your site and app in Search Console.

To associate your app and your website using the App Links Assistant, click Open the Digital Asset Links File Generator from the App Links Assistant and follow these steps:

The App Links Assistant walks you through basic URL mapping Figure 2. Enter details about your site and app to generate a Digital Asset Links file.

  1. Enter your Site domain and your Application ID. 2) To include support in your Digital Asset Links file for Smart Lock for Passwords, select Support sharing credentials between the app and the website and enter your site's login URL. This adds the following string to your Digital Asset Links file declaring that your app and website share sign-in credentials: delegate_permission/common.get_login_creds. Learn more about supporting Smart Lock for Passwords in your app. 3) Specify the signing config or select a keystore file. Make sure you select the right config or keystore file for either the release build or debug build of your app. If you want to set up your production build, use the release config. If you want to test your build, use the debug config. 4) Click Generate Digital Asset Links file. 5) Once Android Studio generates the file, click Save file to download it. 6) Upload the assetlinks.json file to your site, with read-access for everyone, at https:///.well-known/assetlinks.json. Important: The system verifies the Digital Asset Links file via the encrypted HTTPS protocol. Make sure that the assetlinks.json file is accessible over an HTTPS connection, regardless of whether your app's intent filter includes https.

  2. Click Link and Verify to confirm that you've uploaded the correct Digital Asset Links file to the correct location.

You should now be able to see Your app - Installed in Google search results, that's how you know that it has worked

like image 71
ericn Avatar answered Oct 19 '22 12:10

ericn


If you have successfully integrated all steps and your link is verified to be connected to your activity but still not triggering app's activity, then go to app's setting and enable deep linking then select your provided links. This will be auto enabled once you update your release build in play store.

like image 2
VIVek Avatar answered Oct 19 '22 12:10

VIVek