open android app using scheme not working - android

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.

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

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 existing or new activity from browser

I am trying to implement an intent filter but for some reason (unknown to me) can succeed.
I declared activity in the following way:
<activity
android:name="com.example.StartActivity"
android:label="#string/start_activity_title"
android:windowSoftInputMode="adjustPan"
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="myapp"
android:host="terms-signed.com"
android:pathPrefix="/?"/>
</intent-filter>
</activity>
The browser tries to open URIs like myapp://terms-signed.com/?documentKey=SOME-HEX
No matter if I put such URI in the browser address field or if I tap on a similar link in a HTML page, nothing happens.
There is no chooser shown, my app does not become foremost, Android does not launch my app if it's not running. Nothing. Only browser shows page with message that the webpage at the address might be temporarily down etc.
I am using Android 4.2.1 / Galaxy Nexus.
What can be done to make this work?
Remove the ? from the pathPrefix, it is not a part of the path. Maybe you can even remove the whole pathPrefix parameter, as you don't have any path after the host.
Edit2: As it can be seen in the comments, additionally removing the hyphen and the .com from the host declaration resolved the issue. My best guess would be that the browser will treat the URI as a web URI because of the .com, regardless if it is using a custom scheme.

Android Intent-filter not registered using android:scheme on some devices

My android app should interact with our web site doing some streaming. If the user does not have the app installed we provide a webpage informing about the app and link to download it.
The info page is located at: http://my.site.no/android
And all the links are prefixed with this info page: http://my.site.no/android?url=http://something.to.stream
In the app I have declared the following intent filter:
<intent-filter>
<data android:scheme="http" android:host="my.site.no" android:pathPrefix="/android" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
This works for most devices.. but some (especially Samsung Galaxy SIII’s) refuses to register this intent filter. Even though the app is installed the user always lands on the info page. This is not just happening on the standard browser but also with other browsers like firefox and chrome on the same device. There is no “default app” settings active on the devices which refuses to register the intent.
Any idea what might be wrong ? Or how to try to debug this to find the cause ?
Probably you need to register another for the scheme "https". I had this problem with some apps and this solved it.
Had a similar problem. In my case, it was caused by the activity accidentally having set
android:exported="false"
in AndroidManifest.xml. It seems that some devices/Android versions respect this flag and some don't. In my case, it worked on a HTC Sensation (Android 4.0.3), but not on a HTC One X (Android 4.1.1) or a Samsung Galaxy S III (Android 4.1.2).

Categories

Resources