4

I've been trying to use deep linking from a website I own to a resource inside my app. I've been reading about how things has evolved with deep linking in Android, particularly Paul Kinlan's blog post which seems to be the most recent explanation on how things should work.

I also have read this discussion on why custom scheme is a bad practice and should not be used, which made sense.

Now I decided to use the #intent link in my website to open the resource in the app when user taps on the link. For this, I used a link like this:

intent:#Intent;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;i.res_id=80;end

But when I click on it, nothing happens, and I see this in the logs:

chromium: [INFO:CONSOLE(0)] "Navigation is blocked: intent:#Intent;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;i.res_id=80;end", source: http://example.com/?res_id=80 (0)

I then read about this on Chrome documentation, which interestingly, their example was using a custom scheme, contrary to what they had argued before should not be done!

Now if I add the HTTP scheme to my intent link, like this:

intent://example.com/?res_id=80#Intent;scheme=http;package=com.example.project;component=com.example.project/.ui.ActivityWithResource;end

Then it works, because the activity has the intent-filter to handle the urls like http://example.com/, but why when I specify the component, it doesn't work?

Also, when I use HTTP scheme in my intent, in shows activity resolver (except android 6.0 as I do use auto-verify), but I assume if I can get my explicit intent link to work, it should directly open the resource in the app, as I already have defined the component in the intent link. right?

Maybe the only way is to use custom scheme after all?

Thanks

P.S: Here is the activity definition in my AndroidManifest. I wasn't sure if it requires android:pathPrefix to work or not, so I added both intent-filters

<activity
    android:name=".ui.ActivityWithResource"
    android:label="@string/app_name"
    android:exported="true"
    android:screenOrientation="portrait">
    <intent-filter android:autoVerify="true">
        <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="example.com" android:pathPrefix="/"/>
    </intent-filter>

    <intent-filter android:autoVerify="true">
        <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="example.com"/>
    </intent-filter>
</activity>
Community
  • 1
  • 1
m.hashemian
  • 1,786
  • 2
  • 15
  • 31

0 Answers0