Hm...

I assume, getType() is also called by the system whenever it wants to
resolve an intent that contains the data (so that it can look up the
Manifest file for the appropriate intent filter that contains that
MIME type).

So I guess if the argument of getType(..) is not a content URI that
you use in intents, then probably your "trick" is safe after all :-)

I don't know whether some Android folks know of other caveats that one
may like to take into consideration?

Peli

On Jan 15, 3:55 pm, Peli <[email protected]> wrote:
> Nice solution.
>
> However, one point of critique:
>
> >  I can then pass around
> > Synchronisation information (validity, compatibility, version, status,
> > etc) using any of the ContentProvider class methods (I used getType
> > ()).
>
> Probably you should not mis-use getType(), even if all
> ContentProviders act in your own name space. The reason is that other
> applications (maybe a universal backup application?) may peek all
> content providers and call getType() if they are interested in what
> kind of content your content providers provide.
>
> Probably it is safer to use query() on different URI paths, as this
> can return whatever you define it to return - within your name space.
>
> Peliwww.openintents.org
>
> On Jan 15, 2:05 pm, whitemice <[email protected]> wrote:
>
> > Solution
> > The simplest solution (not using intents) is to instruct each user of
> > my component to define a new content provider:
>
> > content://myComponentNamespace.theirApplicaitonNamespace
>
> > Android lets me search through all available content providers, which
> > can be string matched to my own component namespace.
>
> > context.getPackageManager().queryContentProviders(null, 0, 0);
>
> > If I find more than one valid Content Provider I can then pass around
> > Synchronisation information (validity, compatibility, version, status,
> > etc) using any of the ContentProvider class methods (I used getType
> > ()).
>
> > The only problem with this approach is that the application developer
> > who imports my component (as a JAR) will have to define their own
> > custom Content Provider.  This is done by extending the
> > MyComponentContentProvider class (from my JAR) and defining a
> > CONTENT_URI variable.
>
> > package test;
> > import com.whitemice.MyComponentContentProvider;
> > public class TheirContentProvider extends MyComponentContentProvider {
> > public static final Uri CONTENT_URI =
> > Uri.parse( "content://
> > myComponentNamespace.theirApplicaitonNamespace");
>
> > }
>
> > As well as adding the custom provider to the Android manifest.
>
> > <provider
> >         android:name="test.TheirContentProvider"
>
> > android:authorities="test.service.TestContentProvider.TestAndroidContentProvider"
> >         />
>
> > Without the custom Content Provider configuration, Android will behave
> > strangely and sometimes call a different .APK file if it has a class
> > in it with the same name.
>
> > As this is a work time project, I will have to check if I can release
> > the synchronisation code as a working example.  If I do it will appear
> > on my blog here:http://tinyurl.com/9hwdva
>
> > Regards
> > Mark
>
> > P.S. Thanks again everyone for your suggestions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to