One can use SharedPreferences, (This isn't best way for me since I
want it on demand and not be present if app is stopped or uninstalled
)
This might work if you set the mode to Context.MODE_WORLD_READABLE
but I wouldn't recommend it.
Setup broadcast receivers in two apps send intent to broadcast
receiver and pass a reply back intent (I see its always async and thus
doesn't fit my needs, am I missing some info that can make sending
response back from App A -> App B in sync ?? )
I wouldn't recommend that. One should generally avoid situations like this and Intents
weren't meant to be used that way. But for the record: there is a way to send Intents
and receive results synchronously.
Set up content providers in two apps that provide data such as app version and fact we can access the provider we know its running and
installed
This is kind of weird. Why would you use a ContentProvider
to pass data between apps like this? It's essentially the same solution as with the SharedPreferences
. I wouldn't recommend this.
Using PackageInfo to find data about App B package name and find if
its installed, its version name Then use
ActivityManager.getRunningAppProcesses and check if its has App B
process to know if its running.
This really is the best option out of all those you listed. I don't understand why you hesitate to implement it this way? if the information you mentioned above really is all you need than you can get it all from PackageInfo
and ActivityManager
. This way the other app has to do nothing for this to work. The solution is solely implemented in the app which tries to obtain the data.
If you really want to pass bigger amounts or more complex data between apps then I would recommend you write a Service
which the other app can bind to. You could also try AIDL.
You can also take a look at this answer by CommonsWare: android communication between two applications