user1325094
user1325094

Reputation: 339

Writing ICS Android apps which are backwards compatible

I'm writing an app that adds calendar events.

For OS versions prior to ICS, I need to use contentResolver queries which are unsupported and subject to change.

With ICS the API to do this sort of thing is to use the CalendarContract provider. So I plan to detect the OS API version and use the appropriate methods for pre ICS OS and ICS.

In my manifest I have the following to support Android 2.1 to 4.x:

uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14"

But the CalendarContract isn't available to import unless I set the minSdkVersion to 14, which makes the app inaccessible to anyone running anything prior to ICS.

How do I support older versions of the OS while adding support for new OS features on phones with ICS?

Do I create two versions of the app and upload both to the marketplace? Will users see the appropriate version for their OS?

Upvotes: 2

Views: 599

Answers (1)

jsimpson
jsimpson

Reputation: 391

This is what you can do to make this work:

Have the minSDK version set to 2.1 and the target version to ICS.

Then, In properties of your project, build against ICS (android 4.0)..

This way, you are building against 4.0, which will include the functionality you need in ICS, yet you will still support android 2.1

As long as you don't call any ICS APIs when it is running on 2.1 (you will get classnotfound exception if you do), you will be fine.

Upvotes: 3

Related Questions