本文整理汇总了Java中android.content.ContentProvider.attachInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ContentProvider.attachInfo方法的具体用法?Java ContentProvider.attachInfo怎么用?Java ContentProvider.attachInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.ContentProvider
的用法示例。
在下文中一共展示了ContentProvider.attachInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installProvider
import android.content.ContentProvider; //导入方法依赖的package包/类
private ContentProvider installProvider(PluginInfo pluginInfo, ProviderInfo providerInfo) {
try {
Logger.d(TAG, "installProvider() providerInfo = " + providerInfo);
Class clazz = pluginInfo.classLoader.loadClass(providerInfo.name);
ContentProvider contentProvider = (ContentProvider) clazz.newInstance();
contentProvider.attachInfo(pluginInfo.baseContext, providerInfo);
synchronized (mContentProviderMap) {
ContentProvider cp = mContentProviderMap.get(providerInfo.name);
if (cp != null) {
Logger.d(TAG, "installProvider() lose race!");
contentProvider = cp;
} else {
mContentProviderMap.put(providerInfo.name, contentProvider);
PluginManager.getInstance(getContext()).callProviderOnCreate(contentProvider, mStubInfo, providerInfo);
}
}
Logger.d(TAG, "installProvider() providerInfo -> " + contentProvider);
return contentProvider;
} catch (Exception e) {
Logger.e(TAG, "installProvider() error! providerInfo = " + providerInfo, e);
}
return null;
}
示例2: setUpContentProvider
import android.content.ContentProvider; //导入方法依赖的package包/类
private void setUpContentProvider(ContentProvider targetProvider) throws Exception {
mResolver = new ChangeRecordingMockContentResolver();
final String filenamePrefix = this.getClass().getSimpleName() + ".";
RenamingDelegatingContext targetContextWrapper =
new RenamingDelegatingContext(
new ContentProviderMockContext(),
(Context)getActivity(),
filenamePrefix);
mProviderContext = new IsolatedContext(mResolver, targetContextWrapper);
targetProvider.attachInfo(mProviderContext, null);
mProvider = new DelegatingTestContentProvider(targetProvider);
mProvider.attachInfo(mProviderContext, null);
mResolver.addProvider(mProviderAuthority, mProvider);
}
示例3: prepareProvider
import android.content.ContentProvider; //导入方法依赖的package包/类
private ContentProvider prepareProvider(ContentProvider provider) {
provider.attachInfo(this, null);
provider.onCreate();
return provider;
}