1

The application I am working on requires utilising the capabilities of other apps on the device where they are available.

This is the paradigm that Intents and Intent Filters are supposed to handle in Android. I will give one specific example which shows where this falls down (and is practically useless) for all cases.

Example: Using an Intent to pass the content of an MMS to the messaging app:

  1. I go to the Intent class reference and find which system ACTION looks most appropriate (already am guessing - ACTION_SEND vs ACTION_SENDTO vs ACTION_VIEW and assuming that the ACTION is one declared by the system)
  2. I try and figure out if there is a specific Uri to supply for the data (there's this list for Google applications and I'm assuming this is then expected to be supplied by all apps and found individually?)
  3. I now want to find what EXTRA keys should be used to supply the data (message body text, image). I have no idea and no hints whatsoever?

Sure, I can look on StackOverflow and find answers here and here which kind of give the answers I'm looking for (I have not found any answer for providing an MMS with recipient and image simultaneously). But how is this supposed to actually be done generically? How was the non-system, non-generic, sms_body EXTRA key even found by people?

My only answer is to gather the solution directly from the app itself (I think decompiling someone else's work already should not be the right direction but its the only direction I have). So I (this was done with the new Hangouts app that supports SMS):

  1. Download the app from my rooted device using adb in /data/app/
  2. Decompile using apktool and get the manifest file. From this I can see what IntentFilters are defined. I cannot see anything to do with EXTRAs because they are not declarable in an IntentFilter
  3. I try and get the source code by obtaining the classes.dex and decompiling using dex2jar and then view with JD-GUI and attempt to interpret barely readable 'half-decompressed' code to find use of the EXTRAS that are passed in with the Intent.

That was my attempts at doing this, it seems that even at the first step (decompiling other apps) this is not the direction that you should be heading to find out the language to communicate with other apps that explicitly want to be talked to (an app declares an IntentFilter to declare that any data passing that filter, it wants to receive).

The only obvious answer, is that there is something accessible through a class in the Android SDK which apps declare and define information that they would like to receive. The closest I have found in this vein is the PackageManager.GET_INTENT_FILTERS flag which has not even been implmented.

  • How am I supposed to figure out how to correctly generate Intents to pass to apps expecting this data?
  • Most importantly, how should I go about finding the correct EXTRAs to pass in with the Intent? Are they defined anywhere else besides within an apk's source code?

I must be missing something, because in a phone OS that relies heavily on inter-app communication why would it be so difficult to obtain basic communication protocols.

Community
  • 1
  • 1
btalb
  • 6,937
  • 11
  • 36
  • 44

1 Answers1

2

Why are you so sure you're missing something?

I think it is analogue to finding out certain commands an API exposes. If you are in luck (java class, SOAP API with wsdl) it actually tells you what you can do. But if not (REST API) you're "stuck" with reading the documentation. This is an actual possibility, so "how can I do this" doesn't have to have an answer.

In this case, as you found out, there isn't some java-like 'contract' to read and figure out what you can do. Neither is there an accessible file like a wsdl you can use to see what you can do

So you are going to have to read documentation of the apps you want to use. If there isn't one, you might just have to come to the conclusion that that's that.

The solution you found with decompilation is problematic, apart from the technical limitations: as it might be subject to change. If only certain extra's are documented, you are relying on 'hidden' features. A second road, but with the same issues and then some, is trying to find other code that uses the intent (like stackoverflow questions).

Nanne
  • 64,065
  • 16
  • 119
  • 163