Reputation: 620
I am creating an Android application which will scan various aspects of the device (contacts, apns, emails etc)
What I would like to make possible is for 3rd party application to register with my app on install/run/boot etc - making its data available to my application.
How can I access this information in a standard way? I would use some form of Interface if I was creating a typical plugin-style desktop app, but Android doesn't have this ability. I have looked into ContentProviders but the 3rd party app would need to develop a whole SQLite database to allow my app to access its data. This seems overkill.
Is there a way to achieve this?
Upvotes: 1
Views: 480
Reputation: 184
Well Richbayliss, that's an interesting question you've got there. So Android is designed keeping this exact thing in mind - interoperability between applications. So lets break up your question into two main resources:
There are certain things in the phone which are like native to the phone, like the ones you mentioned. So the way it works is something like this:
There are multiple "Managers" in Android (example ClientConnectionManager) which are like the gatekeepers who can access all this native information. They are certainly the easier way to access these resources. You could also access them by going down the sqllite path as you mentioned - an example for this is you could access the photos taken from the camera by using Cursors which eventually look up the sqllite db.
The second part of the question - some other stuff which you want to pass - Let me give you an example of how this works in Android. You basically have to register for certain events in your manifest - say like you want to know every time someone clicks on 'share' - this data you are talking about is bundled and sent across in the Intents. All you got to do is register your application for such calls and declare an activity which can handle a specific kind of event. In short, Talking happens between intents and data is passed in bundles.
Upvotes: 0
Reputation: 1006849
I would use some form of Interface if I was creating a typical plugin-style desktop app, but Android doesn't have this ability.
I have looked into ContentProviders but the 3rd party app would need to develop a whole SQLite database to allow my app to access its data.
No, they do not. ContentProvider
is a facade. You can implement one however you like.
What I would like to make possible is for 3rd party application to register with my app on install/run/boot etc - making its data available to my application.
"Install" won't be possible. On first run and/or at boot time will be possible.
How can I access this information in a standard way?
If your application will be pulling the data, besides a ContentProvider
or an AIDL interface, you could send a command to the third-party app via startService()
and include an extra in the Intent
that provides a channel for the third-party app to use to send its response (e.g., a Messenger
, a PendingIntent
, a ResultReceiver
).
If, instead, the third-party application will be pushing data to you, I'd implement a BroadcastReceiver
, registered in your manifest, and have the third party app send broadcasts as needed.
Upvotes: 2