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:
- I go to the Intent class reference and find which system
ACTION
looks most appropriate (already am guessing -ACTION_SEND
vsACTION_SENDTO
vsACTION_VIEW
and assuming that theACTION
is one declared by the system)- 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?)- 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):
- Download the app from my rooted device using
adb
in/data/app/
- Decompile using apktool and get the manifest file. From this I can see what
IntentFilter
s are defined. I cannot see anything to do withEXTRA
s because they are not declarable in anIntentFilter
- 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 theEXTRAS
that are passed in with theIntent
.
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
Intent
s to pass to apps expecting this data? - Most importantly, how should I go about finding the correct
EXTRA
s to pass in with theIntent
? 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.