I have a library project that I use to build two applications, a public one and a private one for personal usage with few more settings useless to most people. In this library project I define a PreferenceActivity (for API < Honeycomb) and some PreferenceFragments (for API >= Honeycomb), with preference headers using this guide : http://developer.android.com/guide/topics/ui/settings.html#BackCompatHeaders
To support older devices, I define this XML file as shown in the guide :
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<Preference
android:title="@string/base_de_donnees"
android:summary="@string/summary_pref_restaurer_bdd_sd">
<intent
android:targetPackage="com.me.app_lib"
android:targetClass="com.me.app_lib.activities.preferences.SettingsActivity"
android:action="com.me.app_lib.activities.preferences.SettingsActivity.ACTION_PREF_BDD" />
</Preference>
<Preference
android:title="@string/saisie"
android:summary="@string/summary_pref_saisie">
<intent
android:targetPackage="com.me.app_lib"
android:targetClass="com.me.app_lib.activities.preferences.SettingsActivity"
android:action="com.me.app_lib.activities.preferences.SettingsActivity.ACTION_PREF_SASISIE" />
</Preference>
</PreferenceScreen>
Where com.me.app_lib is the package of the library project, in which the SettingsActivity is defined. However, I get a crash when the intent is called from one of the child projects, as the targetPackage does not match that of the child project. If I change com.me.app_lib to com.me.app_public (package of one of the child projects) it works, but as I have two child projects, this is not an option.
Do I have to copy this file to each of the child projects and change only the targetPackage line, or is there a better option ?