Actually it's there because the platform doesn't need the meta-data, so it doesn't make sense to retrieve all of the meta-data for every content provider it instantiates.
If you want the meta data, it is one line of code to call into the package manager to get it, as you've shown. Just do that. On Thu, Jan 13, 2011 at 12:02 AM, jesse <[email protected]> wrote: > hmm, so I need to make explicit call to get ProviderInfo in the MyProvider: > context.getPackageManager(). > resolveContentProvider(MyProvider.class.getName(), > PackageManager.GET_META_DATA); > > even though Override function public void attachInfo(Context context, > ProviderInfo info) already has > a ProviderInfo info variable passed in. > > I understand the limitation is because it is possible to have multiple > providers defined in > manifest file. when attachInfo() is called in base class, it has no > information of > the actual provider class name. > > Can we improve the design like : > > abstract class ContentProvider { > > public void attachInfo(Context context) { > ProviderInfo info = context.getPackageManager(). > resolveContentProvider(getClass().getName(), // <--- getClass() > will automatically resolve to the derived class name. > PackageManager.GET_META_DATA); > > attachInfo(context, info); > } > > public abstract void attachInfo(Context context, ProviderInfo info); > } > > MyProvider extends ContentProvider { > public abstract void attachInfo(Context context, ProviderInfo info) { > // now info.metaData should have value, is not null. > assertNotNull(info.metaData); > } > } > > android platform parses the manifest.xml file new instance of MyProvider > and then initializes it via attachInfo(...) > > so the design will be more clean. please correct me if i am wrong. > > regards! > > > On Wed, Jan 5, 2011 at 10:04 PM, Dianne Hackborn <[email protected]> > wrote: > > You need to request the ProviderInfo from the package manager, setting > the > > flag to tell it to return the meta data. > > > > On Wed, Jan 5, 2011 at 12:20 AM, jesse <[email protected]> wrote: > >> > >> According to this page: > >> http://developer.android.com/guide/topics/manifest/manifest-intro.html, > >> provider can have meta-data. > >> however, when I check providerInfo.metaData in attachInfo() function > >> of a derived provider class, it is always null? > >> > >> is this a bug is android SDK 7? > >> > >> public class MyProvider extends ContentProvider { > >> .. > >> > >> public void attachInfo(Context context, ProviderInfo info) { > >> super.attachInfo(context, info); > >> > >> Bundle bundle2 = info.metaData; > >> > >> However, bundle2 is always null here. > >> > >> > >> here is my manifest xml file: > >> > >> <provider android:name="MyProvider" > >> android:authorities="com.xxxx..MyProvider"> > >> <meta-data android:name="varNme" android:value="xyzzxzxz" /> > >> </provider> > >> > >> thanks! > >> > >> -- > >> 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]<android-developers%[email protected]> > >> For more options, visit this group at > >> http://groups.google.com/group/android-developers?hl=en > > > > > > > > -- > > Dianne Hackborn > > Android framework engineer > > [email protected] > > > > Note: please don't send private questions to me, as I don't have time to > > provide private support, and so won't reply to such e-mails. All such > > questions should be posted on public forums, where I and others can see > and > > answer them. > > > > -- > > 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]<android-developers%[email protected]> > > For more options, visit this group at > > http://groups.google.com/group/android-developers?hl=en > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- 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

