-4

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?

Michael SM
  • 715
  • 3
  • 11
  • 25

1 Answers1

0

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Mark, that you for your answer. maybe this question was asked before or is too naive to ask as 4 people down vote it. I have another question for about cwac-loaderex. How do I use both SqliteCursorLoader and SharedPreferencesLoader in the same ListActivity? They have different types. – Michael SM Sep 28 '13 at 15:16
  • @MichaelSM: You will probably need to implement one set of `LoaderCallbacks` on something other than the activity itself. Using the activity (or fragment) for `LoaderCallbacks` is a convenience for single-loader use cases, but there is no requirement that `LoaderCallbacks` be implemented on the activity (or fragment). If you need additional help on that point, I would suggest that you open a fresh StackOverflow question about how to support 2+ loaders being used by the same activity/fragment. – CommonsWare Sep 28 '13 at 15:45
  • Thanks for your hint. I figured out supporting 2+ loaders in the same activity. For SharedPreferencesLoader, just create a field object subclassing from Loader.CallBack and pass it as the last argument into LoadManager initLoader method. The question is: is it really worthy to have a SharedPreferencesLoader instead of system default? Any evidence to justify its use? – Michael SM Oct 11 '13 at 00:07
  • @MichaelSM: "Any evidence to justify its use?" -- the first time you reference the `SharedPreferences`, they are loaded from disk. If that is done on the main application thread, you are likely to drop frames. You are welcome to use Traceview, determine how long it should take to load your `SharedPreferences`, and decide whether or not you need a background thread at all. And, if you do, it's still up to you whether you use a `Loader` for it or not. – CommonsWare Oct 11 '13 at 10:23