NitZRobotKoder
NitZRobotKoder

Reputation: 1086

Android Application: Stop using Deprecated API's on new API level enabled device

Well we started an application with support from API Level 8 i.e Froyo verison. Now we being on API level 18 Jelly Bean version, how do we stop using deprecated API's on my application.
One Example
Dialog(API 1) vs DialogFragment(API 13)
Following are in my mind
1)Use Android Support Library Good way to go?
2)Have a runtime API level check as below, is this a healthy habit?

if (Build.VERSION.SDK_INT==Build.VERSION_CODES) {//Some API Level
run a code
}else if(){
run a code
}


3) Use reflection?
4)Have separate code base to each API level,makes no sense.
5)Does Palystore allows us to uplaod multiple Apk's based on API level.Or the complete control is on uses-sdk manifest value.

<uses-sdk android:minSdkVersion="integer"
      android:targetSdkVersion="integer"
      android:maxSdkVersion="integer" />

What will be the best way use latest API's with only one code base and make one APK and inturn have backward comparability support.

Inputs will be much appreciated.

Upvotes: 0

Views: 450

Answers (2)

n8udd
n8udd

Reputation: 711

Why not upload the existing application as a "legacy version" of the application, that supports older version of the app, and continue to develop the existing application for newer devices?

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006594

One Example Dialog(API 1) vs DialogFragment(API 13)

Dialog is not deprecated. Ways of using Dialog may be deprecated, such as the old-style managed dialogs.

Use Android Support Library Good way to go?

Generally, yes.

Have a runtime API level check as below, is this a healthy habit?

Yes, though usually you use >= or <=, not ==, to drive behaviors for a range of API levels.

Use reflection?

I wouldn't.

Have separate code base to each API level,makes no sense. Does Palystore allows us to uplaod multiple Apk's based on API level

In some extreme cases this may be required. Most apps should not need this.

What will be the best way use latest API's with only one code base and make one APK and inturn have backward comparability support.

That is impossible to answer in the abstract.

Upvotes: 1

Related Questions