Of course you can.
You can define old xml with ContactsSource in default xml folder
And create second xml with ContactsAccountType in xml-v11 folder.
Question
I have been experiencing a small problem with the contacts application for android 2.1 where my app causes the contacts application to crush when displaying contacts due to the contacts xml definition.
<ContactsAccountType
xmlns:android="http://schemas.android.com/apk/res/android"
viewContactNotifyService=".ContactViewedService">
...
</ContactsAccountType>
The error that was being displayed was :
05-01 12:43:31.960: E/AndroidRuntime(1064): FATAL EXCEPTION: main
05-01 12:43:31.960: E/AndroidRuntime(1064): java.lang.IllegalStateException: Top level element must be ContactsSource
05-01 12:43:31.960: E/AndroidRuntime(1064): at com.android.contacts.model.ExternalSource.inflate(ExternalSource.java:133)
05-01 12:43:31.960: E/AndroidRuntime(1064): at com.android.contacts.model.ExternalSource.inflate(ExternalSource.java:104)
05-01 12:43:31.960: E/AndroidRuntime(1064): at com.android.contacts.model.ContactsSource.ensureInflated(ContactsSource.java:98)
05-01 12:43:31.960: E/AndroidRuntime(1064): at com.android.contacts.model.Sources.getInflatedSource(Sources.java:311)
I managed to trace and found that I needed to switch ContactsAccountType to ContactsSource in the contacts.xml file which is deprecated so my question is:
Is there a way I can have contactsSource for lower api versions as a fallback and ContactsAccountType as the default in my xml description?
Solution
Of course you can.
You can define old xml with ContactsSource in default xml folder
And create second xml with ContactsAccountType in xml-v11 folder.