Android Custom URL Scheme for different apps - android

I would like to create a series of apps that will be opened via URL scheme. What I would like to do is to use the same base scheme for all of them but be able to specify which app to open... somthing like this:
myApp://open?appUrl="app1" -> open first app
myApp://open?appUrl="app2" -> open second app
etc...
Is it possible?
THX

You can do it using <intent-filter> in your <activity>:
<activity android:name=".activity.Activity">
<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" />
<data android:host="app1" />
</intent-filter>
</activity>
this should work for myApp://app1, I am not sure if intent-filter can parse more complicated URLs like open?appUrl="app1"

Yes this is possible. You'll need to specify the URL scheme within the corresponding BroadcastReceiver of your apps.

Related

prevent the app to be displayed in ( open as dialog ) for specific keywords in url using manifest intent filter

Right now in my manifest code I have
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<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:scheme="https" />
<data android:scheme="http" />
<data
android:name="default-url"
android:host="#string/bc"
android:scheme="#string/bc" />
</intent-filter>
which allow the user to get open with dialog if he click on URL that start with domain of my application for example: pop-up dialog to select the app
and its working fine, however, I'm facing an issue when the user request forgets password he receives a link on his email to reset his password.
the link he received is like this: www.domain.com/forget_password/email.
what I want is to keep the app link working but if the domain contains /forget_password open the browser by default, not the application.
Sorry, there is no "exclude" logic in <intent-filter>. You cannot create an <intent-filter> that says "I accept everything except this".
You will need to handle the forget_password path in your app, perhaps by launching a Web browser yourself.

Deep Links and Instant Apps

I am attempting to implement deep links within my Instant App, and keep running into issues that seem to be coming from something to do with the base application. Currently, the error I'm receiving from the Play Console states:
You should have at least one active installed app APK that mapped to
site 'example.site.com' through a web intent-filter.
I do have an intent-filters set up in both the instant app and in the full base app. The intent-filters in the base application look like this:
<intent-filter>
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
<intent-filter>
<data
android:scheme="https"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
And the intent-filters in the instant app module's manifest look 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="https"
android:host="example.site.com"
android:pathPattern="/test/app/" />
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>
With the instant app manifest also containing a default url, set up within the activity tag.
I'm not sure what I am missing here. I have set up the intent filters as I've seen elsewhere on the web, in Google's documentation, and in other forum posts where I've seen people encountering issues with this process. I've also hosted the assetlinks.json file in the .well-known directory on my domain, and verified that it is correct and accessible using Google's verification API. Does anyone know what the issue causing this error may be? Thanks!
From what I have read in the documentation you need to make sure that you use an intent-filter with autoVerify, action and categories for the app as well. In your example you can simply copy & paste the intent-filter that you are using in the instant-app to your full app.
In case you are using string resources for scheme, host or pathPattern I would try to avoid this and directly enter your values in the manifest instead.
e.g. (crafted from your post)
<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="example.site.com"
android:pathPattern="/test/app/" />
<data
android:scheme="http"
android:host="example.site.com"
android:pathPattern="/test/app/" />
</intent-filter>

Launch Android App from Shorten URL ( Through DeepLink)

There is a perfect way to launch our android application through Deeplink.
<activity
android:name="com.example.android.GizmosActivity"
android:label="#string/title_gizmos" >
<intent-filter android:label="#string/filter_title_viewgizmos">
<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"
android:pathPrefix="/gizmos" />
</intent-filter>
</activity>
Here, I can easily launch my application through “http://www.example.com/gizmos”, But my question comes when I am going to hit shorten URL of this link i.e. goo.gl/tNQpWe.
What could be the ways to launch my app through tiny/ shorten url too ?
Please suggest.
The short url will be redirecting to your server/domain and from there you do the same what "gizmos" did. Deep linking is basically a HTML page rendering some expected data by your android application (In your case android:host and android:pathPrefix)
You will need to create a basic html rendering the android schema if you need data to be passed. I would suggest you to follow Branch.io.
https://blog.branch.io/technical-guide-to-deep-linking-on-android-chrome-intents

How to intercept click on specific url and open own webclient -- Android

I'm doing a chat, and In this chat, some messages will be links to a specific url (this url opens a document viewer in the server).
The links look, like this: http://X.X.X.X:8080/DocumentViewer/...
Then I have a webview activity, where I want to open this type of links.
How can "intercept" when the user clicks on this type of links, and open my own webview and not open a "external" browser?
I think that you can accomplish this by creating an intent-filter in your AndroidManifest.xml file for the URL pattern that you are interested in. The documentation for the intent-filter's <data> element shows how you can specify a host and a scheme ("html" in your case) to handle URLs.
This answer shows an example where the developer wanted to handle youtube.com URLs. I have included the manifest snippet below for completeness:
<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="www.youtube.com" android:scheme="http" />
</intent-filter>
Based on this, I think (I have not done this myself) that your intent filter should look something like:
<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="http://X.X.X.X:8080/DocumentViewer/" android:scheme="http" />
</intent-filter>

How to call an app mobile via web view?

is there a solution to call a mobile app via a link in a web page(my web page is a web view in a mobile app). For example, I want to call facebook app when tap on a link.
You need to create an <intent-filter>. See Launch custom android application from android browser.
For the simplest case, you need to add something like this to your AndroidManifest.xml:
<intent-filter>
<data android:scheme="http" android:host="your-url-.com"/>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
You have to add an Intent filter in Manifest file like this -
<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="www.tamrakar.in"
android:path="/test"
android:scheme="http" />
</intent-filter>
Hope this helps.

Categories

Resources