I am now advanced in developing my 15-activities android app which is based on the latest API (15 ICS). Now I discovered that main functionalists of the app is NOT backward compatible even with the android v4 support such as:
1-fragmentTransaction animation 2-the ability to putStringSet in sharedPref 3-having mapActivity using fragments
I thought about making a second version for the older OS's of EACH class that has incompatibility issues (which are around 10) so I use them if I detect that the device running the app is old. However, I am sure this is a stupid way and there is a better way of doing this.
What is the best way to make your code compatible with API 7 and up without leaving the the features provided higher APIs ( at least to be used for the newer devices )
You can check the API level in android at runtime and enable the required features as per the API level.
Something like below.
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
// Do something for ICS and above versions
} else{
// do something for phones running an SDK before ICS
}
Additionally you can add the version qualifier to the resource folder such as drawable-v15 (will pickup drawables if the device API level is 15)
Check this LINK for more information on how to specify the required qualifiers for the resources
with this the latest functionality available will be enabled when launched on latest firmware devices and backward compatibility is enabled otherwise.