Instant Apps with NFC - android

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

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

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

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>

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

open android app using scheme not working

I feel stupid as I have found three different questions which seem to be the same as mine, but I can't get it to work. I tried "Open Android app using intent-filter not working", "Open Android app from URL using intent-filter not working", and "Open Android app from URL using intent-filter not working for 4.1 version 2". My app captures activity on my mobile web site using a WebView, but I know a lot of my users use Google to launch their browser. I would like instead for it to launch my app. In addition, it would be nice when a user types the address of my site into a browser, they would get a selection dialog to give them the option of using my app for my web site. My Manifest has the following:
<activity android:name=".MainActivity">
<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" />
<data android:host="www.tennisrecruiting.net" />
<!--<data android:pathPattern="/.*" />-->
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I have tried it with and without the commented out line, and with the pattern ".*" but none of them work. That is, if I type "tennisrecruiting" into a google search, and click on a choice that takes me to "http://tennisrecruiting.net", the phone goes directly to my Chrome browser without asking to use my app. Similarly, if I am in my chrome browser and type "http://tennisrecruiting.net" as the target URL, chrome just opens my site without launching my app or asking the user for a choice.
What am I doing wrong - other questioners seem to get it to work but I have tried all of their solutions and they don't work for me. I have a Galaxy G6 on Verizon with Android version 6.0.1, Kernel version 3.10.61
I figured out my own problem but thought it would be good to post the answer in case someone else has the same problem. The problem was that I only had one browser, Chrome, on my device and it was, of course, registered for the http scheme. Since it was the only one, my device treated it as the preferred app for all http schemes. My scheme was more selective by designating a host. The solution was to download another browser so that none were user preferred, then when Google was navigating to http://tennisrecruiting.net, my app was listed for selection. I still don't get a transfer or selection when my mobile website is entered into Chrome but that is not surprising.

Android Intent Filter to receive image files is only working in some apps

I'm experimenting with android development. As an exercise I want to create an app that is able to receive images shared by other apps. I'm testing the app on my phone.
If i share an image in WhatsApp everything works as expected. My app is listed in the share dialogue and the activity is started. But if try to share an image from any other app (e.g. Photos, Album, Gallery) my app is not listed as on of the options.
I'm using a standard Android Studio project and added only the following lines to the manifest.
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="ANDROID.INTENT.CATEGORY.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
Why isn't my app listed in the other apps? What do I have to change to make it work?
Android is case-sensitive. By having ANDROID.INTENT.CATEGORY.DEFAULT, you will not match any Intent that is seeking android.intent.category.DEFAULT. Change the case to android.intent.category.DEFAULT, and you will match more activity requests.
In fact, since android.intent.category.DEFAULT is added by default to Intent objects passed to startActivity() or startActivityForResult(), I am not quite certain how your activity worked with WhatsApp...

Categories

Resources