Search code examples
androidinstallationlistenerandroid-contentprovider

Receive notification when a new content provider is installed/registered


I have been trying to develop an app that will deal with content providers {contacts, calendar, docs, etc} and their sync options. Although the app works well for existing providers, there might come a time when the authority is not pre-defined. In that case my app can do nothing.

What I need to do is to listen for when a new content provider is installed/registered. For example, if I download Google docs from the market, it registers itself as a provider, so my application should be able to realise that and deal with it accordingly.

Can anyone help with this? I have searched online for two days and unless I'm doing something wrong in the search string, I have no answers thus far. Any help is appreciated, and thanks in advance.

-Sreedevi.


Solution

  • There is no way to detect when a new ContentProvider is installed.

    What you CAN do is detect when a new package is installed (see http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED) and then use the PackageManager's PackageInfo interface to list all the ContentProviders the new package has (see the ProviderInfo[] array).