Android - Setting the app's default "Open supported links" option - android

How can I control the default Open supported links to either Ask every time or Open in this app for my Android app? Does it happen in the manifest?
I have two apps that try to accept the same universal link scheme, and the ideal behavior is to have the user decide which app to open when they click on the link. However, it seems that the first app correctly has the Open supported links in settings set to Ask every time, while the other app has the Open supported links as Open in this app. Thus, when both apps are installed, only the second one will be opened straight away, whereas the first one won't even be prompted.
The portion that accepts universal links in both of the AndroidManifest.xml files are almost identical.
<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="foo.bar.com" android:pathPrefix="/action/" android:scheme="https" />
</intent-filter>

Related

Android deep link intent doesn't work on some devices

I have an app that listens for a deeplinks starting with example:// The app can be launched by scanning a QR code containing a deeplink.
<intent-filter>
<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 "example://” -->
<data android:scheme="example"/>
</intent-filter>
I am using the code above. It works exactly as expected on Samsung hardware. My other test device is a Google Pixel 5a. When using the google default camera with my app installed, The camera sees a deeplink starting with example:// my app is not part of the "open with" list that appears.
Any ideas what may be causing this?
It looks as though this is a bug specific to the Pixel camera app. The app is treating all example:// links as though the destination is a web browser, even though http:// or https:// is not included

Instant Apps with NFC

I'm trying to get an instant app to be opened via NFC.
I have something like the below in my AndroidManifest.xml
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:scheme="http" />
<data android:host="example-refresh.herokuapp.com" />
</intent-filter>
When going to https://example-refresh.herokuapp.com (example link obviously) from a link click the instant app loads correctly. When opening that link from an nfc tag the browser just loads. I've tried also having the nfc open an AAR (https://developer.android.com/guide/topics/connectivity/nfc/nfc.html#aar) this results in the play store link opening when the app isn't installed and the app correctly opening from the nfc when it is installed. If I have something else on the nfc so it shows the disambigious options then I can select instant app for the browser option, but I would like for it to default to instant app.
Is there something I'm missing to get an nfc tag to load an instant app? I've also tried using branch, but with no luck.
Instant apps have a very limited set of allowed permissions and NFC is not in that set. Thus any NFC related intent will not work. Besides, whatever you define on your manifest only works when your app is installed. Which obviously is not the case for instant apps. Google does index the android.intent.action.VIEW intents when you upload your APK to Play Store, so they can make instant app works.
So when you scan an NFC, it is an android.nfc.action.NDEF_DISCOVERED intent, and therefore your app won't be launched
However, you still can make it work. Instead of using the link you would normally use to launch your instant app, you should write the link to your instant app on the Play Store to your NFC tag.
https://play.google.com/store/apps/details?id=<package_name>&launch=true
Check https://developer.android.com/distribute/marketing-tools/linking-to-google-play#Instant

Android deep link: App chooser is triggered for each subdomain

So I have an app with deep linking that can open links from the company website.
I do this by adding an intent-filter to an Activity tag like so:
<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="*.company.com"
android:scheme="https" />
</intent-filter>
The problem is that the website has multiple subdomains that each trigger the app chooser. (category1.company.com, category2.company.com etc)
If it were using only one domain, the app chooser would appear only once when opening the main page, the user would choose to continue in the browser "just once" and navigate the website without interruption.
With subdomains, each time the user navigates to a different subdomain he sees the app chooser and has to click "just once" again.
Is there any way to configure the app to display the app chooser only the first time you go on that domain and not for each subdomain?
Have you try several data block in the same intent filter
<data
android:host="category1.company.com"
android:scheme="https" />
<data
android:host="category2.company.com"
android:scheme="https" />
....
use app-ink instead, so android will not ask and just open your app.
you can use a wildcard since Android 6 to include all subdomains.
https://developer.android.com/training/app-links

Deep Linkng: Open Multiple Apps with same host but different pathPrefix

I am using Deep Linking in my application. But, now I have a requirement of opening two seperate apps on two seperate url's but same host like
http:www.google.com/Nexus5 - This should open App1
http:www.google.com/Nexus6 - This should open App2
The above url opens both the apps, but my requirement is that If I provide complete url like http:www.google.com/Nexus5 then it should only show option to of App1.
So, its like if I pass on url
http:www.google.com/Nexus5 then only Nexus5 app should open and show option to browse the app. There should be no option to open Nexus6 app.
Same way for http:www.google.com/Nexus6 if I open Nexus6 url the it should not show option of Nexus5 App.
Below is my AndroidManifest file for that Activity,
<activity
android:name=".DeepLinkDemo"
android:label="#string/app_name">
<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:host="www.google.com"
android:pathPrefix="/Nexus5"
android:scheme="http" />
</intent-filter>
</activity>
Now, this will run fine but if there is any other app with same host that means www.google.com I want to restrict that app from showing in the Browsable list(that other app will also be controlled by me)
So, is there anyway for achieving my above requirement?
Let, me know if anyone has any query!
You can use android:pathPattern to uniquely identify different application

Select application to open links with in Android

I want to write an app that allows me to remotely start downloading a torrent on my desktop from my phone. How can I change android to open magnet links with my app? I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
EDIT:
Something like this?
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="magnet" />
<data android:host="*" />
<data android:mimeType="application/myApp" />
</intent-filter>
I'm trying to find a non-browser specific solution that can be executed on install without the user having to go through settings.
Im not quite sure I understand what exactly you are trying to do with links. But I can tell you that it probably isn't going to work the way you want it on any stock devices. There is no mechanism within the system to let your application start doing anything right after it is installed. At the very least the user is going to have to choose to use your application to handle whatever links you are trying to override.

Categories

Resources