我正在尝试使用以下代码在我的设备中获取联系人可写帐户列表
public static final String SYNC_META_DATA = "android.content.SyncAdapter";
public static final String[] METADATA_CONTACTS_NAMES = new String[] {
"android.provider.ALTERNATE_CONTACTS_STRUCTURE",
"android.provider.CONTACTS_STRUCTURE"
};
final Intent intent = new Intent(SYNC_META_DATA).setPackage(resPackageName);
final List<ResolveInfo> intentServices =
pm.queryIntentServices(intent, PackageManager.GET_META_DATA);
if (intentServices != null) {
for (final ResolveInfo resolveInfo : intentServices) {
final ServiceInfo serviceInfo = resolveInfo.serviceInfo;
if (serviceInfo == null) {
continue;
}
for (String metadataName : METADATA_CONTACTS_NAMES) {
final XmlResourceParser parser = serviceInfo.loadXmlMetaData(
pm, metadataName);
if (parser != null) {
return parser;
}
}
}
}
但我总是将 XmlResourceParser 解析器设为空。所以请帮助我如何获取android中的联系人可写帐户列表