I know it's possible to communicate with native android components via the Intent call, but I'm trying to figure out how to launch an app (which is installed) through an Adobe Air application.
Currently, thanks to Ben, I know that...
var url:String = ("intent:#Intent;" +
"action=android.intent.action.MAIN;" +
"category=android.intent.category.LAUNCHER;" +
"component=com.android.settings/.Settings;" +
"end");
navigateToURL(new URLRequest(url));
...launches the Android Settings menu through an Air app, which is awesome.
But I'm trying to launch an app...and I believe the secret lies within the "component=com.android.settings/.Settings;" snippet. Does anybody know how I can modify this code to launch an installed app on a device?
My kingdom for an answer. I've scoured the internet for days searching on this.
Brad
It depends on your use case.
If there's one specific app you want to open, you can look inside that app's .apk for the <intent-filter> elements, as explained in Launch custom android application from android browser. Then craft the appropriate URL to pass to navigateToUrl().
Another possibility is to get the package name for the app you want to open and set that as the component= section of your URL. Fair warning, I'm not actually sure if that will work.
If you don't know what app you want to open at compile-time, it's harder (e.g. if you have a server-side list of applications that your AIR app may need to invoke). Launch an application from another application on Android shows how to launch an application if you only know the package name, but you'll need a native extension to enable that functionality.
Related
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.
I have been asked to make an iOS / Android app that simply opens a website on full screen.
I have told them that, by using the iOS / Android native option to "Add to Homescreen" would accomplish the needs, but they insist on making it completelly automatic for the end-user.
Am I doomed to make both Apps for this need? Is there any way to "automatically create" or "share" an already created homescreen shortcut?
Thanks for your time.
Yes, you are doomed to make two apps, but you can start with a cross platform framework that can output to both platforms, allowing you to write it once. From how you describe this project I recommend starting with Cordova.
As maddy points out in the comment, an app that simply displays a website will be rejected by Apple. Yet if you encapsulate them website inside Cordova app, where the app need not access the website, or only access a website for updated information you will probably be approved.
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.
I am working on an Adobe AIR app that will run on Android devices. The current issue I am facing is that I have received a jar file that contains an Android Activity that launches the camera, recognizes an image, and returns an id code back to the application letting the developer know which image was recognized. Thus, I need to launch the Activity from the AIR app and then return to the AIR app with the id code accessible. Is this possible?
I have read several answers regarding communicating with an AIR app via Android, but I haven't found any for communicating with an Activity via an AIR app.
Thanks so much!
You can start an intent on Android with navigateToURL(), details are described here:
Launching intents
For the data return, your AIR app can register a custom URI scheme which the native app can use to talk back to your app:
Custom URI scheme
Alternatively, you can use (or maybe find it somewhere) an ANE that uses startActivityForResult() native Android API to achieve two-way communication in a single call. AIR doesn't support that by itself, I believe.
I am creating an app that i would like to have apps running within it like let's say an iframe on a website. Is this possible? For example i will open my app and it will show the Gallery of the phone but while running my app, and not just by opening the gallery app which will make my app minimized. I want it exactly like an iframe, is this possible?
you can not run another app within your own application. You can do any of the following two
start the other app by sending intent message
or create the other app's features similarly in your own app.
According to your question if your need is to create a gallery then why aren't you creating a own gallery in your app? that will be more easier and flexible
You can not run another app's Activities within your app in an iframe style for security reasons, sorry.
Yes, I believe that is is possible for Apps to run cross platform if there exist a common data framework that creates a uniform standard for how data is stored and referenced. So the data can exist in the cloud but referenced via each app independently of the mobile phone platform.