Android - how to find Intent for installed app(s) - android

I know that an App (app2) I have installed on my device can be called from another App (app1). As app1 has a button that will bring up app2. Is there a way to determine what that Intent looks like to start app2 on my device? I want to modify my own app to do the same thing.
For example, this page on the Android Developers site shows you how to make implicit Intent calls for action.
https://developer.android.com/training/basics/intents/sending
But, is there a way to discover what Intents/Activities another App allows/makes-visible such that I can call app2 and open it?

App1 takes some contextual data and starts app2 with that data opened to the pertinent page
You are assuming that app2 has an activity supporting some Intent designed to do that.
Is there a way to determine what that Intent looks like to start app2 on my device?
Talk to the developer of app2.
There are a number of common Intent structures (ACTION_VIEW, ACTION_SEND, etc.). Using PackageManager, you can find out if app2 supports one of those. Through a fair bit of complexity, there are ways that you can get to the manifest and find the <intent-filter> structures supported by any given app2 on a device.
If you are referring to manually examining app2 to see what it supports, there are apps like this one that you can use.
Can I find out what key/value pairs it supports also?
Talk to the developer of app2. That information is internal to the app and is not published in places like the manifest. If app2 happens to be open source, you can examine the source code.

Related

Is it possible to interact to other app like getting the id what view they tapped?

I'm developing an application that can determine the id of view on external app,
(e.g. I have two application, App1 and App2, what I'm going to make is App2 that can determine what App1 doing, like getting the id of the button on App1 using App2 and if gets an error the App2 will catch the log error)
is it possible?
You can interact between 2 application using bound service and Android Interface Definition Language (AIDL).
Check below link for more details.
https://developer.android.com/guide/components/bound-services.html
Other solutions are communicating with a server that stores the information that you need.
Or write the actions on a file accessible by both apps.
Obviously, all the solutions have pros and cons. In the first one, you need to have access to the internet, on the second you need to handle readings and writings simultaneous, etc.

Return message from called phonegap app

I have two apps created using Phonegap and, at the moment, they run only on Android devices. I call app2 from app1 using Intent. How can I have a return message (or something like this) from app2 to app1?
Thanks.
Omar
So app2 is somehow launching an intent to open up app1 and you want to pass some information from app2 into app1? Intents have a putExtra method that lets you attach more information to them that you can later read in app1; see this stackoverflow question: How do I create an android Intent that carries data?
Now, getting this to work with Cordova might be a bit more tricky - how are you launching the intent? If it is some sort of phonegap plugin, there is probably a way to use putExtra.

Control an application from another application

I read this question and another question and I understand how to launch an application from another application (Let's call the other application LauncherApplication). However, my goal is not only to launch an application, but to use its functions, so I suppose the LauncherApplication should start an activity using an intent (explicit or implicit).
I should know the data and the actions the installed applications react on and I should add these information to an intent instance before starting it. I wish LauncherApplication allows the user (not the developer) to configure this intent, but how do I know in advance the parameters to put in an intent for the installed applications?
I should implement the "LauncherApplication* in order to allow the user to construct an intent via a graphical interface. Or I could make my application supports the addition of plugins: in this way, I could create a plugin for each installed application, where each plugin could be responsible to manage the configuration of the intent concerning the application associated with it.
UPDATE (added details). In particular, the LauncherApplication should be a service with a speech recognizer enabled, so the user may start an application uttering specific keywords: as well as launch an application, the user should be able to close it and use its functions.
For example, I could have installed an application ((Let's call it LibraryApp) to search for available books in a library; this application could have the following functions:
Search for a book (this function may return if the book is available, it has already been loaned or if it was booked by someone else).
Reserving a book (this function should return the completion of the reservation).
In this way, when I pronounce, for example, the words "start LibraryApp", then the LauncherApplication service should launch the LibraryApp application. Once the application is launched, the service should be able to send commands to it to use one of the available functions (search for a book, reserving a book).
How can I send commands to application that is already active, in order to control it?
how do I know in advance the parameters to put in an intent for the installed applications?
You talk to their developers. There are typically zero "parameters" on an Intent to launch the launcher activity (or activities) of an application, since home screens do not put such "parameters" on the Intent.

LauncherActivity usage

Could you please explain me purpose and usage of LauncherActivity? Documentation says that it "Displays a list of all activities which can be performed for a given intent". I understood that it should automatically build list of all activities found in application and provide their launching. Am I right?
And how to use it? I have found no examples in the web.
Google Code shows the class code itself... It has a different constructor than is described in the Android Platform API.
public abstract class LauncherActivity extends ListActivity {
Intent mIntent;
PackageManager mPackageManager;
IconResizer mIconResizer;
Your phone can have more than one possible app which handles a given intent. One great example is opening a webpage. There's the stock WebKit based browser, you can install Firefox Mobile, Dolphin Browser, Opera Mini... When they all advertise that they can handle a given intent, how does the device know which one it should pass the intent to?
Android will use a LauncherActivity to bring up a selection list of packages where each one listed is one that knows how to do something with the given intent you provide it. When you pick one, you're picking which app you want, and the intent is routed to the matching app.
From that perspective, it's a class that's really part of the Android OS support code, part of figuring out where to distribute given intents to. It's hard to see a situation where you would need to involve yourself with it directly... you should be able to just call StartActivity(Intent), which throws the intent over the wall to the OS, and at that point the device itself should fire up LauncherActivity on its own (if it's even needed).
Completely unrelated (and horribly name-disambiguated) is your application's "Launcher Activity" (documentation) -- an activity that shows in AndroidManifest.xml with an intent filter with "android.intent.action.MAIN" and "android.intent.category.LAUNCHER" ... This is how your app advertises to the system that it wants to have an icon in the device's application list, and that a specific activity should be started when that icon's clicked. You absolutely need to do that.

Intent resolution in Android

If I want to create custom address book (which overrides my phone's default address book), and if I want it to be used by all applications, what should be my intent-filter? Does Android allow me to do such a thing considering the fact that such a third-party app could potentially be malicious?!
And, if I want to have yet another address book application, I suppose the second app also has same intent-filter, isn't it? How does the framework decide which app to pick if I click on Contacts button when making a call? In other words, how does the framework resolve intents in case,there is a conflict between multiple intent-filters?
You can replace any application on Android platform, even Home. Android documentation explains everything there is to know about Intents and Intent Filters and there is a section called Intent Resolution that answers your question. Intent Resolution section for Intent class has some additional information.
As far as I can tell Android doesn't try to resolve a conflict. It ask the user which application to run and gives them the choice to mark this Activity as the default for this Intent. They give an example about mail app here.
While Mr. Smiljanić is basically correct, there is no Contacts application in Android for you to replace. There is Dialtacts, which is the application supporting the contacts, call log, and dialer. That application cannot be replaced, mostly because the dialer cannot be replaced.
So, while you may be able to override some intent filters and get control on some contacts-related requests, you will be unable to get the contacts portion of Dialtacts overridden, which will confuse users.

Categories

Resources