3

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:

  1. 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).
  2. 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?

Community
  • 1
  • 1
enzom83
  • 8,080
  • 10
  • 68
  • 114

1 Answers1

3

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    So, how can I make the _LauncherApplication_ configurable to control the installed applications (for example, to open a video on youtube, or to send an sms to a phone number, etc.)? – enzom83 Apr 21 '12 at 17:09
  • 1
    @enzom83: Since you have not explained what "LauncherApplication" is actually supposed to be, I cannot really answer that question. Perhaps you might consider reading http://developer.android.com/guide/topics/intents/intents-filters.html to learn more about the process of using `Intents` to start up activities and do other things. – CommonsWare Apr 21 '12 at 17:39
  • 1
    I added some details to my question. – enzom83 Apr 23 '12 at 14:47
  • 2
    @enzom83: Then the documentation I linked to is what you need. You are also well-advised to read the documentation for standard implicit `Intent` actions on the `Intent` class (e.g., `ACTION_VIEW`) for what should be included in those `Intents` (e.g., `Uri` to the data, MIME type). You would need to determine how to handle the chooser dialog (e.g., the user has 18 SMS clients installed and needs to pick one). And for anything outside what is documented on `Intent`, as I originally wrote, you need to talk to the developers of the app in question. – CommonsWare Apr 23 '12 at 14:57
  • 1
    Ok, no problem for the chooser dialog: I will use an explicit intent to launch specific applications chosen by the user! – enzom83 Apr 23 '12 at 15:35
  • 1
    I read the documentation about intent and filters, but I did not understand how I can send commands to an application that is already started. The only way to send an intent to a specific component is to pass it to the `startActivity` method, but if the activity is already active on the screen, is there a way to send data to it? – enzom83 Apr 26 '12 at 21:16
  • 1
    @enzom83: No, sorry. What you are trying to do ("a service with a speech recognizer enabled") must be implemented at the firmware level, at best. It might require writing your own mobile OS. – CommonsWare Apr 26 '12 at 21:24
  • 1
    I think I solved the problem by using the `onNewIntent` method defined in `Activity` class. – enzom83 Apr 26 '12 at 21:55