本文整理匯總了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;
}