Manually open hyperlinks in specific app in Android - android

I use the Twitter app to follow a lot of news outlets. Each one of them posts links to articles on their websites. I want to open those articles in the news outlet's dedicated Android app. Some of them, like the NYTimes app, does it by itself. But most of them don't. I'm figuring that's because they haven't declared an intent in their app to do so. So basically I want to write an app that would give me an option to redirect the hyperlink of the article to a specific app, and I want to do it for multiple apps. Would it be possible to create a regex that would run on the URL and redirect it to the proper app accordingly?

Would it be possible to create a regex that would run on the URL
That is impossible to state in the abstract. Android's <intent-filter> system does not allow for filtering on all parts of a URL.
and redirect it to the proper app accordingly?
That is impossible to state in the abstract:
There is no requirement for the app for a news site to have any means for outside apps to tell it what to view
There is no requirement for an app's developers to document how to convert a Web site URL to whatever input would be available to tell the app to go view something
So, what you want may be possible for some news apps, but the details would vary by app.

Not that I am aware of - though this is an interesting concept.
Here are some things to know:
the twitter app doesn't care how the intent is resolved. the purpose of the intent is to share external data. once the twitter app has handed over the intent with the url it is up to the android system to decide which app can resolve.
the NY Times app is capable of opening because of this feature: https://developer.android.com/training/app-indexing/deep-linking.html
Workaround:
Learn to develop your own Android ROM to modify the Android Open Source Project adding your logic for intent resolution, compile and get your new Android ROM ready for deploy, install ROM on phone, keep your fingers crossed the entire time.

Related

In mobile, can different apps respond to a browser call-to-action and open directly?

I'd like to design a cross platform protocol that any app on mobile or app on your desktop can respond to.
On desktop the best example is torrents, where you have a magnet link of the form magnet:?urn:btih:abcabcabcabcabcabcabcabc etc. that can be opened by any app that supports the magnet: scheme. There also exists .torrent files which can be opened by anything that supports .torrents (although this won't open directly).
Is something like this possible on mobile? From my initial research it appears that iOS doesn't let multiple apps register the same uri scheme so customuniversalscheme:// won't work. I also vaguely recall mobile safari opening files in browser and not in separate apps or even being able to download the files, but i'm not sure about that anymore...
What about android? Can multiple apps respond to the same custom scheme? Files can be downloaded on android, but can files be opened directly in browser?
Is the user flow I am thinking about possible on mobile? If so, how? If not, what's the next best alternative?
So I think your comparison with the desktop torrent flow is a bit wrong. On desktop you can choose the default app to open a file or you can "Open With" an app that you want, on mobile it's a little bit different and more complicated.
So mainly on mobile platforms you open an app with a deep-link and iOS has two ways of deep-links:
the old and well known URL scheme that you defined above
the universal-link, this one is used a lot (iOS 9 and above) to forward a link, that usually will be opened in browser, to the app that responds to the universal link (it's very similar to the URL scheme thinghy)
For Android you have something similar using intent-filters and as far as I know it's possible to have multiple apps that respond to the same deep-link, but if I remember correctly the user will be prompted with an app picker (to select which app to use).
Now this is a short summary about deep-links, but from my experience the main issue with deep-links is now how you create them, it's about the app that must "forward" them. For example, on Android there are so many web browsers (not chrome) that won't forward the deep-link to the system in order to check if there is an app that can open them.
Now, if you can pass this problem, what I think you could do to unify the implementation for both platforms is to link your framework/lib/app to an API that will generate a unique deep-link scheme for every app. For example I want to "respond" to your deep-links so I register my app on your platform, with the bundle id and package name (which are unique), and your system will generate a unique combo of package name / bunde id and other number. When your lib/app/framework launch you will fetch all the configured bundles and try to fire a deep-link for each of them, this approach is kind of limited by the number of registered apps.

Get referring url for Android or iOS installation

We have several landing pages that link to Google Play and iOS App Store. I would love to know the landing page that a person came from within the app code. I have searched around and can't find any clear answer. Lots of gray area.
I just want to access the landing page URL in Java or Swift.
I realize iOS and Android are two separate beasts. But does anyone know how I could achieve this?
You will need to use Firebase Dynamic Links this helps you create various links using various alternatives as shown in this quote from the official Firebase source:
You create a Dynamic Link either by using the Firebase console, using a REST API, iOS or Android Builder API, or by forming a URL by adding Dynamic Link parameters to a domain specific to your app.
Then your app can access the link in code using Java or Swift and the link will work even if the user has your app already in their phone and you can set a logic to handle that too and the links are also automatically direct the user to AppStore or PlayStore depending on which device is used.
Dont worry about whether the link will work for both Android and iOS and you can use the api to access the link as this quote says.
With Dynamic Links, your users get the best available experience for the platform they open your link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content on your website.
In addition, Dynamic Links work across app installs: if a user opens a Dynamic Link on iOS or Android and doesn't have your app installed, the user can be prompted to install it; then, after installation, your app starts and can access the link.
You can get more information on dynamic links here and check if it will solve your problem.

Linking to external android apps through html

I'm a First time developer who is developing a basic WebView based app for android devices. I have some links that lead to profiles on facebook, twitter & instagram etc. At the moment whenever these links are clicked the relevant profiles open but in website form and not app. How can I make these links open the relevant app instead of the website. For example whenever I click on instagram it loads the mobile website for instagram instead of launching the actual app. Also if I have a telephone number set using href="tel: how can I set it to launch the phone app with the telephone number filled in. Sorry if these are stupid questions but I am very new to app development and am still learning. Many thanks for your time.
You will need to use the application specific URL schemes:
A good read on what this is:
https://fokkezb.nl/2013/08/26/url-schemes-for-ios-and-android-1/
Once you understand what this is you will need to do some research to find the URL scheme and correct url for every app you want to target
Example: fb://profile/
Phone number this might work: 2125551212

How to prevent Chrome from opening App Links

I have an android application say Sample App. I want to add App Links according to Android Developer Guide. I was successful in implementing them, but there was an problem with Chrome. When I access the corresponding Sample Web App and there is <a> tag with href="https://www.sample.com/profile" and it's also supported by App, it opens in app instead of continuing in Chrome.
I checked documentation and it is supposed to be default behavior of Chrome. But then I came across Linkedin app. The My Network tab they have when clicked in browser continues in browser but same link if I save to docs or any other application and click it then it opens in native app.
I want to know how this is done?
I believe this is because, as you said, the standard deep linking behavior is to route to the app if it is installed. This behavior is handed-off immediately when the link is clicked because your app overriders that url to be handled by app instead of Chrome.
First, I believe that you should route users to your application because its a better, more engaging experience, presumably.
If you are convinced, then I would change your manifest to strictly handle links that you want to handle. See this post to see how to handle only certain links.

Launching Google Finance and display graph on a particular Stock, is that possible?

I would like to do two things within my Android app :
Check if the Google Finance app is installed on the device. Should be pretty straighforward, isn't it ?
If yes, launch an intent to Open up Google Finance, displaying a graph on a particular Stock. So I also need to pass the stock ticker to Google Finance in some way... but is this even possible ?
Any other alternative I could use to display Stock Charts (let's say a 5 days intraday chart) on any stock ?
Thanks for your help.
I am not aware of there being any publicly-documented packages or Intents to achieve your aim, let alone an Intent that would meet your specific open-a-graph-on-a-stock request.
Since I am assuming you are looking for something that is free, I would look into launching the Browser (or perhaps using the WebView widget) on some existing Web-based finance site.
Unfortunately, very few intents with parameters are published and documented.
OpenIntents tries to collect some of them http://www.openintents.org/
Another way of finding available intents is to look at the AndroidManifest.xml of the deployed application (usually only compressed, not encrypted). Of course, this method discovers intents that may not be public and will change over time.
Recently came across ManifestExplorer https://www.isecpartners.com/manifest_explorer.html which I have built into an .apk at http://dl.dropbox.com/u/4379928/android/ManifestExplorer.apk
It allows you to see the AndroidManifest.xml of all installed applications.
The manfiest of com.google.android.apps.finance doesn't include any relevant intents.
However, it is interesting that it contains a data scheme for http://finance.google.com so that if you use the browser to navigate to this page it asks if you want to open it in the finance app instead.
Best way would probably be to follow the advice from CommonsWare

Categories

Resources