I have a flutter app. I've declared an intent filter in AndroidManifest.xml like this:
<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="test" android:host="test.example.com"/>
</intent-filter>
(I'm not using test.example.com but a domain I actually control.)
I've then set up a web server which serves links like https://test.example.com/?token=xyz into HTTP 301 redirects to test://test.example.com/?token=xyz. The idea is that I'll send a user an email with the first link, which will result in a redirect to an intent which my app receives and this is how the app gets authenticated with my web service.
This all works when I test it on a real Android phone. But when I'm running it in the Android emulator running a Pixel XL API 31 ROM, I can't figure out how to send the intent directly. I'm trying this:
$ adb -e shell
emulator64_x86_64_arm64:/ $ am broadcast -a android.intent.action.VIEW -c android.intent.category.DEFAULT -c android.intent.category.BROWSABLE test://test.example.com/?token=xyz
Broadcasting: Intent { act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT,android.intent.category.BROWSABLE] dat=test://test.example.com/ flg=0x400000 }
Broadcast completed: result=0
This looks successful but nothing happens. As far as I can tell, the app doesn't catch the intent. Am I doing something wrong?
Related
My AndroidManifest.xml contains:
<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="books.com" android:pathPrefix="/book" />
</intent-filter>
And it is opening my app with the correct page when running
adb shell am start -a android.intent.action.VIEW -d "https://books.com/book/my-book-123" -c android.intent.category.BROWSABLE
or
adb shell am start -a android.intent.action.VIEW -d "https://books.com/book/my-book-123" com.books.app
When I send https://books.com/book/my-book-123 via email or message app, it just opens the browser when I tap it.
If I remove android:pathPrefix="/book" it works, but then every url will open the app while I only want to open the books.com/books urls
I've checked that in my phone that books.com does not have set the "always open" set to my browser.
According to this, Web links are deep links that use the HTTP and HTTPS schemes. On Android 12 and higher, clicking a web link (that is not an Android App Link) always shows content in a web browser. On devices running previous versions of Android, if your app or other apps installed on a user's device can also handle the web link, users might not go directly to the browser. Instead, they'll see a disambiguation dialog.
Android App Links
Android App Links, available on Android 6.0 (API level 23) and higher, are web links that use the HTTP and HTTPS schemes and contain the autoVerify attribute. This attribute allows your app to designate itself as the default handler of a given type of link. So when the user clicks on an Android App Link, your app opens immediately if it's installed—the disambiguation dialog doesn't appear.
So in a few words, you have to prove that you own that domain to be able to do what you´re trying to do, otherwise the web browser will load the URL.
I created a cordova application for ios and android, where the user must create an account. He then receives an e-mail containing a link, on which he must click to validate the account. How do I get the link to open in the app rather than the device browser? I have seen information on deep-links, but is this the correct way to do that?
You should define url in manifest under activity
<intent-filter
android:autoVerify="true"
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.geeksempire.net"
android:pathPrefix="/createshortcuts.html"
android:scheme="https"/>
<!-- command to TEST >>> adb shell am start -W -a android.intent.action.VIEW -d "https//...." net.geekstools.floatshort.PRO -->
</intent-filter>
Also check this https://developer.android.com/guide/components/intents-common
I feel like this is an embarrassingly stupid question, but oh well, as long as I get an answer.
The purpose of an app intent Nearby Notification is that users who tap the notification will be taken to the Play Store to install an app if they don't have it, or it will open the app if it is already installed. My problem is that, even when it is already installed, tapping the notification always takes me to the Play Store listing for the app.
In the Google Beacons dashboard, I select a beacon from the list and then select "View Nearby Notifications" from the dashboard. I enter a title, the language, ensure production mode is selected, select "App intent" from the dropdown. Then I have fields for intent scheme, intent path, package name of the app.
Is an intent path required?
Why isn't a host required?
I'm unclear about what intent filter I need to set in my AndroidManifest.xml. This is what I am trying:
<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="nearbyapidemo"
android:host="name.chadschultz.nearbyapidemo"/>
</intent-filter>
What am I doing wrong?
A kind developer in real life pointed out my mistake. This is all I need to add in AndroidManifest.xml for the Activity I want to start:
<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="nearbyapidemo"/>
</intent-filter>
I did NOT need a value for the host. Silly mistake on my part!
And then when I configure the beacons, I simply need to enter the scheme (whatever arbitrary value I entered for the scheme in AndroidManifest.xml and then the package name of the app. I can leave the path blank in both the manifest and the Beacon Console.
Now when I tap the Nearby Notification, it will install the app if not installed, or will open the app if it is installed.
Another tip I learned: I can test the Intent directly from ADB via
adb shell am start -a android.intent.action.VIEW -d "nearbyapidemo://" name.chadschultz.nearbyapidemo
(Replace nearbyapidemo with your scheme and name.chadschultz.nearbyapidemo with your package name)
Of course, the best test is to update the bluetooth beacon and tap the Nearby Notification when it appears.
I wrote an app that has the following BroadcastReceiver :
<receiver
android:exported="true"
android:name="com.package.InstallReferrerReceiver" >
<intent-filter >
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
The intent fires fine when I am using
am broadcast -a com.android.vending.INSTALL_REFERRER
-n com.example.gatestapp/com.google.analytics.tracking.android.CampaignTrackingReceiver
--es "referrer" "utm_source=testSource&utm_medium=testMedium&utm_term=testTerm&utm_content=testContent&utm_campaign=testCampaign"
But, on uploading this app as a Beta version, it doesnt seem to fire (in the receiver,it should contact a webservice).
I made the link and sent it to people in messages.They opened the referral links in the browser.
What could the problem be ? Is it that it wont work for Beta? or , is there any 'correct' way of downloading from the play store via play ?
I'm using an Activity with an intent filter similar to the one described here to be able to intercept clicks in the browser and give the user the option to open the my app instead. Here's the code from my AndroidManifest.xml:
<activity android:name="com.scompt.ScomptIntentFilter">
<intent-filter>
<data android:scheme="http" android:host="www.scompt.com" />
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
This isn't working if I enter http://www.scompt.com into the browser. The page is loaded, just like normal.
If I enter either of the following commands on the command line, then I'm given the standard chooser between my app and the browser, as I would expect.
adb -d shell am start -d http://www.scompt.com -a android.intent.action.VIEW
adb -d shell am start -d http://www.scompt.com
Is there any other place I should look to get this to work? I've verified what I'm doing with the open-source hubroid and I seem to be doing the same thing.
With regards to intents there is a distinct difference between a user typing a URL into their browser and following a link in a web page, email etc.
An intent WILL be fired as you expect if you follow a link on a browser web page or a link in an email.
However, when the user types a URL into the address bar of their browser Android believes that the user specifically wants that URL to open in the browser and therefore does not fire an intent.
So if you want to test URLs and intent filters then you need to setup a static web page with hyperlinks on it or send an email to your phone.
When you think about it this system works in a similar fashion to the default browser behaviour in Windows. Imagine your default browser is Chrome but you also have Firefox installed. If you click a link in an email it will open in Chrome. If however you open Firefox and type a URL into the address bar and hit go it DOES NOT open in Chrome because clearly you want the URL to open in Firefox.
http://example.com isn't http://www.example.com.
Try typing http://www.example.com into the browser and see if that works.
This is the manifest code that works for me:
<activity
android:name="MY_APP"
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="MY_HOST"
android:scheme="MY_SCHEME" />
</intent-filter>
</activity>
add pathPatterns to data tag:
<data
android:host="www.example.com"
android:scheme="http"
android:pathPattern=".*">
</data>
<data
android:host="example.com"
android:scheme="http"
android:pathPattern=".*">
</data>
I had exactly the same problem as of 28 Jan 2014 with chrome browser.
check my answer here
Launch custom android application from android browser