0

I am trying to build an app that will be compatible with low versions of Android. On the other hand, I noticed that if I set the target SDK Version to a higher value (like 19), some features work better; in particular, animations are a lot smoother. So -- the Manifest:

<uses-sdk android:targetSdkVersion="19" android:minSdkVersion="7" />

In addition, although the app knows how to restart itself, it does not fully do so. I prefer to handle resizes without closing the app. Therefore, I have the following in the Manifest:

android:configChanges="mcc|mnc|locale|keyboard|keyboardHidden|screenLayout|fontScale|uiMode|orientation|screenSize|smallestScreenSize|layoutDirection"

So far, so good. Now, what do I put in the project.properties?

target=android-19 shows a lot of warnings on deprecated methods. If I try to fix them by using "replacement" methods, it would result in the compiled code incompatible with API-7.

target=android-7 gives me an error in Manifest since screenSize and some other configuration change options aren't defined.

Advice?

user1334767
  • 587
  • 4
  • 17

1 Answers1

0

If I try to fix them by using "replacement" methods, it would result in the compiled code incompatible with API-7.

Check at runtime what the Android version is and do different things for different versions:

if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.HONEYCOMB) {
    // do something
}
else {
    // do something else, if needed
}

(where you substitute the right Build.VERSION_CODES value for your use case).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • OK, makes sense. I can use this approach if some deprecated method is completely killed off. For the sake of code clarity, I do not want to explicitly use any SDKs beyond API-7. I was wondering if there was any method that would a) keep everything compatible with API-7, b) get rid of warnings, and c) let me keep screenSize in Manifest. – user1334767 May 28 '14 at 01:26
  • @user1334767: not in any sensible fashion. You can always disable warnings. – CommonsWare May 28 '14 at 01:39