I want to launch Android application on clicking URL (may be in e-mail or SMS).
How to write different path patterns for these two URL?
http://www.hostname.com/folder1/file.ext
http://www.hostname.com/folder1/folder2/file.ext
I want to launch my activity only from the first URL, not the second one. Currently I am using this intent-filter but it's launching my app with both URL.
<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.hostname.com"
android:pathPattern=".*\\/folder1/*"
android:scheme="http" />
</intent-filter>
Try below code
<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.hostname.com"
android:pathPrefix="/folder1"
android:scheme="http" />
</intent-filter>
Related
I need to match urls ending in /*-u.html, e.g. https://www.example.com/something/whatever-u.html.
I've tried android:pathPattern="/.*-u.html", which works for the above url, but it doesn't work if there's a hyphen anywhere else in the url, e.g. https://www.example.com/some-thing/whatever-u.html. At first I thought there was something special about the hyphen character, but then I realised the same happens with any character that follows the .*.
I've tried many other combinations but can't find one to reliably match the above url format. I know that PatternMatcher is limited, but I assume it should be possible to match this?
Edit: Here's a video of the issue, using the patterns suggested in PraveenSP's answer below.
I think this should work:
android:pathPattern="/.*/.*-u.html"
Try to do it like this
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="*.yourhost.com"
android:pathPattern="/.*\\/.*-u.html"
android:scheme="https" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="*.yourhost.com"
android:pathPattern=".*-u.html"
android:scheme="https" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="*.yourhost.com"
android:pathPattern="/.*\\/.*-.*-u.html"
android:scheme="https" />
</intent-filter>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.VIEW" />
<data
android:host="*.yourhost.com"
android:pathPattern="/.*\\/.*-.*-u.html"
android:scheme="https" />
</intent-filter>
Tested cases :
https://www.example.com/some-thing/whatever-u.html
https://www.example.com/something/whatever-u.html
https://www.example.com/something/what-ever-u.html
https://www.example.com/some-thing/what-ever-u.html
I have following intent filter set up for detecting links to open in our app.
<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="share.example.tv"
android:pathPrefix="/"
android:scheme="https" />
<data
android:host="example.tv"
android:pathPrefix="/u"
android:scheme="https" />
</intent-filter>
I want my app to open below 2 links
https://share.example.tv/tv34gh
https://example.tv/u/some-user-name
But my app is showing up for these links as well
https://example.tv/anything/literally-anything
If I separate both of the links in different intent-filters for same activity like below
<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="share.example.tv"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
<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="example.tv"
android:pathPrefix="/u"
android:scheme="https" />
</intent-filter>
This works but I don't know why.
I'm trying to configure deeplinks for my app. I configured several options like:
https://myapp.com/news ---> NewsActivity
https://myapp.com/history ---> HistoryActivity
with intent filters like:
<intent-filter android:label="MyApp">
<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="myapp.com"
android:pathPrefix="/news" />
</intent-filter>
and
<intent-filter android:label="MyApp">
<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="myapp.com"
android:pathPrefix="/history" />
</intent-filter>
I also want a link pointing from the base domain to my main activity
https://myapp.com ---> MainActivity
I want the link to respond to the base domain but no to other links like: https://myapp.com/playlists since the playlist features is not currently implemented in the app and is better to redirect to the web.
But when I set the intent filter:
<intent-filter android:label="MyApp">
<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="myapp.com"
android:path="" />
</intent-filter>
I receive the following lint warning:
android:path cannot be empty
Ensure the URL is supported by your app, to get installs and traffic
to your app from GoogleSearch.
More info: https://g.co/AppIndexing/AndroidStudio
Despite this warning, the behavior it is correct. How can I fix this warning?
Had the same issue, you can just ignore the warning with tools:ignore="AppLinkUrlError"
So your intent would be:
<intent-filter android:label="MyApp">
<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="myapp.com"
android:path=""
tools:ignore="AppLinkUrlError" />
</intent-filter>
Add xmlns:tools="http://schemas.android.com/tools" to your initial manifest tag if it's not already there.
I added a deep linking to my Android app this way:
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<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="https"
android:host="example.com"/>
</intent-filter>
</activity>
When I click on https://example.com I get redirected to the web site.
When I change android:scheme="https" to android:scheme="appscheme" it works and it redirects me to my app.
How to force my app to be opened via https scheme?
UPDATE
I added a subdomain and it still doesn't work.
<activity
android:name=".views.DeepLinkActivity"
android:exported="true">
<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="https"
android:host="www.example.ru"/>
</intent-filter>
</activity>
Thanks to veritas1 I removed android:autoVerify="true" from https-scheme. I also changed the scheme from https to http. (You can read about autoVerify).
So, currently have two different schemes:
<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="your-site.com"
android:pathPrefix="/"
android:scheme="http"
/>
</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:host="your-site.com"
android:pathPrefix="/"
android:scheme="myapp"
/>
</intent-filter>
When clicking on a link myapp://your-site.com/... an application will be opened. When clicking on http://your-site.com/... Chrome browser will offer to open in the application or another browser, while other mobile browsers ignore this and try to open themselves.
UPDATE
See https://stackoverflow.com/a/60342565/2914140 for App Linking.
Hi please use the following data and try also refer this doc
<intent-filter>
<data
android:scheme="ou unique scheme(appname,package name)" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
OR
<data
android:scheme="you unique scheme(appname,package name)"
android:host="www.example.ru"/>
You refer to deep linking but android:autoVerify="true" is used for App linking, so the domain example.com (which you don't own?) is going to get checked for a digital asset links json file. See https://developer.android.com/training/app-links/index.html
For your test to work I'd suggest removing android:autoVerify="true" and adding a subdomain to the host e.g. android:host="www.example.com"
Try this
<activity
android:name=".views.DeepLinkingActivity"
android:exported="true">
<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:host="open"
android:scheme="example" />
</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:host="example.com"
android:pathPrefix="/"
android:scheme="http" />
</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:host="example.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
Please check below it may be help
https://codelabs.developers.google.com/codelabs/android-deep-linking/index.html?index=..%2F..%2Findex#0
Just use http. Don't know when the implementation is changed.
But I just tested that using http will make both http and https work.
So change you intent filter by:
<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>
youe can also add to it
sub.example.com
<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="http" android:host="example.com" />
<data android:scheme="app" android:host="com.example.example" />
</intent-filter>
<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="appname"/>
</intent-filter>
I tried that but still my app won't show up in the list of browsers when I click on any link. What might be going wrong?
use this filter:
<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"/>
</intent-filter>