what is the best coding strategy for supporting pre-3.0 devices with android support library and after-3.0 without it? [closed]

StackOverflow https://stackoverflow.com/questions/19066863

문제

Some library has 2 implementations: one for native 3.0 API and another for ACL support. For example Mark Murphy's enhancement for the Loader framework. https://github.com/commonsguy/cwac-loaderex

So how to cope with it?

도움이 되었습니까?

해결책

The general pattern is that you use the backport so long as your android:minSdkVersion indicates that you need the backport.

So, if your android:minSdkVersion is set to 10 or lower, you will:

  • Need to use the Android Support package's backport of fragments, if you want to use fragments or loaders

  • Need to use ActionBarSherlock or the App Compat backport of the action bar, if you want to have an action bar

  • Etc.

Once your android:minSdkVersion rises to the level that you no longer need the backport, you can (carefully) switch your imports and such to use the native implementation of the capability, rather than the backport. Or, in the case of libraries like CWAC-LoaderEx, switch your imports to use the classes that work in tandem with the native implementation of the capability.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top