Deep linking: id as host - android

I added this code in my Activity in AndroidManifest.xml:
<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:path="*" />
<data android:scheme="schemetest" />
</intent-filter>
Then I have tested two deep links:
schemetest://videos
schemetest://542325
The first is working fine but the second one is not even considered.
When I modifiy it to: schemetest://542325q for example, it works.
So my question is: are numbers allowed as host?
Thanks a lot.

Related

Regex in intent-filter of Android Manifest

I am trying to include a regex in order to implement deeplinking to my activity. We have to activities that share a similar schema which is as follows:
Activity A - http://www.google.com/a/process?abc=xyz
Activity B - http://www.google.com/a//?pqr=efg.
Now I declared the deeplink in the manifest as follows :
<activity
android:name="com.xyz.samples.ActiivtyB" >
<intent-filter android:label="SimpleB">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.com"
android:pathPrefix="/a/"
android:scheme="http" />
</intent-filter>
</activity>
The above declaration for Activity B resolves both urls (mentioned above) since they share the same path till '/a/'.
However this is not the problem with Activity A, since its manifest is declared as below :
<activity
android:name="com.xyz.samples.ActiivtyA" >
<intent-filter android:label="SimpleA">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.com"
android:pathPrefix="/a/process"
android:scheme="http" />
</intent-filter>
</activity>
Hence I came thought of using "regex" which identifies urls of type /a/, I verified the regex here and it is working. Even I wrote a simple Java program to verify this and it is working fine. The regex is /a/)(?!\bsuccess\b).*
When I tried to create the deeplink with the above regex, app is not able to resolve the URL of type http://www.google.com/a//?pqr=efg. The manifest is updated as follows :
<activity
android:name="com.xyz.samples.ActiivtyB" >
<intent-filter android:label="SimpleB">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="www.google.com"
android:pathPattern="(/a/)(?!\\bsuccess\\b).\\*"
android:scheme="http" />
</intent-filter>
</activity>
Any help or insights on how to declare regex in manifest will be really helpful.
I gone thru the Android documentation here and updated the regex accordingly.
You mis-escaped your pattern - .\\* matches the literal string .*. But also:
pathPattern isn't a real regex, but a weird subset of regex. I don't think there's a way to exclude /a/success with those options.

Android Deeplinking not working with multiple schemes

I am stuck with the following scenario. I defined the following deep link intent filters in the AndroidManifest.xml
Expected behavior is when I found a url of format http://​www.domain.com/a/blabla or when there is link in SMS/eMail of format domain/xyz the system should trigger my activity.
Case #1: Working fine
<activity
android:name=".MYActivity">
<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:host="xyz"
android:scheme="domain" />
</intent-filter>
</activity>
Case #2: Working fine
<activity
android:name=".MYActivity">
<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="www.domain.com"
android:pathPrefix="/a"
/>
</intent-filter>
</activity>
Case #3: NOT working
<activity
android:name=".MYActivity">
<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:host="xyz"
android:scheme="domain" />
<data
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a"
/>
</intent-filter>
</activity>
Any suggestions/points/help is really appreciated
I placed both the deeplinks in two different intent filters and it worked!!!.
See the documentation of <data>: it states that:
All the <data> elements contained within the same <intent-filter> element contribute to the same filter.
Hence
<intent-filter>
<data
android:host="xyz"
android:scheme="domain" />
<data
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a" />
<intent-filter>
is interpreted equivalently as (not real code)
<intent-filter>
<data
android:host="xyz"
android:scheme="domain"
android:scheme="http"
android:host="www.domain.com"
android:pathPrefix="/a" />
<intent-filter>
which clearly has some contradictions, for example host being xyz VS www.domain.com.
From Android official documentation site :
Although it's possible to include multiple elements in the same
filter, it's important that you create separate filters when your
intention is to declare unique URLs (such as a specific combination of
scheme and host), because multiple elements in the same intent
filter are actually merged together to account for all variations of
their combined attributes.
You will have to create separate intent-filters.
Slightly off topic but relates the the OP question above with extra information that might help someone else.
If you have intent filters with deeplinks across multiple manifests and want to merge them without overriding each other you can add a unique android:label on your <intent-filter>.
Example:
main/AndroidManifest.xml
(These deeplinks are available to all app flavours, debug, prodcution etc)
<intent-filter android:label="main_deeplink1">
<data
android:host="domain.com"
android:scheme="https" />
<intent-filter>
debug/AndroidManifest.xml
(These deeplinks are available only to the debug build flavour)
<intent-filter android:label="debug_deeplink1">
<data
android:host="dev.domain.com"
android:scheme="https" />
<intent-filter>
The merged Manifest file will now contain both deeplinks without overriding each other.
Here is the tutorial I hop it helps
Tutorial link

android magnet link data filter

I want to launch an Android activity from my app when the user selects a magnet link in the browser.
According to the docs, A URI is specified by separate attributes for each of its parts:
scheme://host:port/path or pathPrefix or pathPattern
The problem with magnet links is that they have a different pattern, like magnet:?xt=......
I tried something like this
<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="magnet"
android:host="*"
/>
</intent-filter>
but it did not work (the activity didn't launch when I opened a magnet link in my browser). Could you help me in correctly declaring an intent filter for magnet links?
I got this to work for me:
<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="magnet"
/>
</intent-filter>
Basically, I removed android:host

Android Intent-filter mimetype and host/scheme

I've seen in some apps that when you click on a link it asks you if you want to open it in an app. I've seen in many posts that you can do
<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:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>
I haven't tried it, but every post seems to say it works. What I tried was:
<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:mimeType="vnd.android.cursor.item/vnd.example.crag" />
<data android:host="www.ex-ample.com" android:scheme="http" />
</intent-filter>
and it doesn't seem to work, I clicked on a link in a text that went to www.ex-ample.com/test/123 and it just opened in a browser.
I'm really wondering two things:
can you use a mineType and a host/scheme attribute together
can you see anything else wrong with this?
can you use a mineType and a host/scheme attribute together
Yes, at least according to the docs on <data>.
can you see anything else wrong with this?
If http://www.ex-ample.com/test/123 does not return a document of MIME type vnd.android.cursor.item/vnd.example.crag on an HTTP HEAD request, your <intent-filter> will not match.

Link from Android browser to my application not working

I want from the android browser be able to launch my application if it's installed, or launch my website in the other case.
So in order to make it work, I put :
<activity android:name=".MMLogin" android:label="MeetMe" android:theme="#android:style/Theme.NoTitleBar" android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="http" android:host="meet-me.com" android:path="/signin" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
in the Manifest, and I created a dummy link to test; and it's not working.
I've tried with and without: BROWSABLE and DEFAULT
I've tried with meetme://datas and change the scheme; nothing worked.
I used threads on stackoverflow like :
Launch custom android application from android browser
What am I doing wrong, or is there a special thing to do to make it work ?
My application suppports from API 7.
Cheers
I used :
Intent Filter to Launch My Activity when custom URI is clicked, I think what was missing is this block :
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/myapp" />
</intent-filter>

Categories

Resources