Reputation: 1124
So the objective is to create some unique type that will open with my app only. This should happen throughout the OS. Ex: suppose my app opens when you click a number like #12345678.90. Where ever this type of number appears, it should automatically become a link and open my app on clicking it. Is it possible?
Upvotes: 1
Views: 341
Reputation: 1007359
So the objective is to create some unique type that will open with my app only
By definition, that is impossible for an SDK app. If you can write the code to support responding to some action, so can anybody else, and the user is welcome to install 2+ apps that contain such code.
This should happen throughout the OS
That too is impossible, unless you build your own ROM mod that somehow forces all occurrences of some string to magically become clickable and magically route to your app.
The closest thing to what you are seeking is if your app has an <intent-filter>
with a <data>
attribute that matches a pattern supported by Linkify
, akin to Benoit's answer. Many apps use Linkify
, directly or indirectly (e.g., via android:autoLink
on a TextView
), to make substrings clickable without any programming. However:
Linkify
does not support arbitrary patterns
Not every app uses Linkify
, and if your string shows up in those places, it is not necessarily going to be clickable
Any app can support the same pattern as you (e.g., Benoit's example will be supported by browsers, as well as your app)
Upvotes: 2
Reputation: 4599
Yes sure if you use deep linking
You need to add the following lines to your activity in the AndroidManifest.xml
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="gizmos" />
But this only works if you have an uri with whatever scheme you may wish.
Can it be different than #12345678.90? or is this the requirement?
Upvotes: 2