How to open an application from a URL? - android

My objective is to open my android application when user clicks link e.g I have shared specific item link (http://example.com/api_shirts.php?utmsource=shirt98) then if user have already installed my application then open it else where open it on browser.
I have searched a lot and get this but it's not working for me
<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"
android:host="www.example.com" />
<data android:scheme="https"
android:host="www.example.com"/>
</intent-filter>

I'm not sure if you may need to set a pathPrefix on this case. Also, the OS may open other prefered app that the user has set up as default app for that schema.
If I remember correcly you have to associate your app with your website so the OS can open the app directly bypassing the user's choice:
https://developer.android.com/studio/write/app-link-indexing.html#associatesite
Also, check https://developer.android.com/training/app-links/verify-site-associations.html to read about "deep links" vs "app links". You need app links for what you are trying to do.

Related

Android AppLink prompting for app and chrome

I am trying to implement an AppLink (deeplink) such that when the app-link is triggered it does not bring up the popup asking for my App or Chrome, I want it to just launch my app so I can direct them to the proper place in the app.
I have read various android articles and posts and cannot get the AppLink to work the way I want.
Here is my manifest xml:
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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:scheme="http"
android:host="www.example.com" />
</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:scheme="https"
android:host="www.example.com" />
</intent-filter>
</activity>
I read in the android doc here the following:
A deep link is an intent filter that allows users to directly enter a
specific activity in your Android app. Clicking one of these links
might open a disambiguation dialog, which allows the user to select
one of multiple apps (including yours) that can handle the given URL.
For example, figure 1 shows the disambiguation dialog after the user
clicks a map link, asking whether to open the link in Maps or Chrome.
Android App Links are a special type of deep link that allows your
website URLs to immediately open the corresponding content in your
Android app (without requiring the user to select the app).
I added auto verify to the intent and have the assetlinks.json file but still prompts to choose my app or chrome. I DO NOT want the prompt for chrome... only my app.
So, what am I missing?
Has anyone here got an app link to work that DOES NOT pop up the option for Chrome?
Can anyone point me to a sample app or code or an article that actually works?
Thanks for any assistance with this.

How do I open a link from an NFC tag?

I want to write a NFC tag that opens a specific note in Google Keep when touched.
I have an URL in the form of https://keep.google.com/u/0/#LIST/<id> that does the desired action of opening the note in the installed Google Keep app on my phone when I read it with a QR-reader or click on it as a link.
When I write this URL to the tag an touch the tag afterwards, it opens in the browser. Is the NFC handler skipping other apps and opening it directly in a browser? When I clear the app-defaults for the browser, it shows a selection menu for the installed browsers after tapping the tag. Does anyone have an idea what I am doing wrong?
Links on NFC tags are not launched as intents with the typical VIEW action. Consequently, other apps may not pick those links up correctly and you will instead experience the web browser to be opened. Only apps that specifically register for the intent action NDEF_DISCOVERED will be able to receive links from NFC tags. It seems that Google Keep currently does not do this, so there's not much you can do without creating your own wrapper app that handles these URLs and passes them on to Google Keep.
You should enable deeplinks in your activity. Also you should indicate your activity NFC tag discoverable as follows. You can learn anything about deep linking via this link
<activity
android:name="ExampleActivity"
android:label="Example">
<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:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>

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

How to open my application directly by clicking on a link from mail?

I am looking for a solution so far, i.e When user clicks on a link from his mail box My Application should open if My Application is already installed in his device without asking user to choose options with Just Once and Always .For example, clicking a URI in an email from a bank might result in a dialog asking the user whether to use the browser, or the bank's own app, to open the link, But in my case my application should open directly without asking to choose any option.
I have implemented my application as follows:
My manifest file as AndroidManifest.xml
<activity android:name=".WelcomeActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.example.com"
android:scheme="http"
android:pathPrefix="/blog"></data>
</intent-filter>
</activity>
My example url is http://www.example.com/blog
I would like to open my application if user clicks on above link.
Please help me with sample code with steps.
This feature is only available on Android devices running at least Marshmallow (6+) and is referenced as App Link throughout the Android documentation.
To fully implement this feature, it requires you to own the corresponding url and add a configuration file at this address: https://www.example.com/.well-known/assetlinks.json. The file content is described in the documentation (contains the package name and its signature).
Then, modify your intent-filter as follow to enable the auto-verify feature:
<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="www.example.com" android:pathPrefix="/blog" />
</intent-filter>
You should definitely read the documentation about this feature. It contains a lot of usefuls tips to test your implementation.

Make third party browser as default

Can anyone tell me how can we make our browser as default in Android? I want to do so that
when you open up the internet browser, it gives you two options: regular browser and Mybrowser (third party browser which is made by me). If you select the regular browser, it says that the phone cannot access the internet unless it is on the Mybrowser. Can we implement this feature, and how?
set this in your AndroidManifest.xml for your activity:
<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="http" />
</intent-filter>

Categories

Resources