Search code examples
androidandroid-support-libraryandroid-appcompatandroid-library

Writing an Android library: use AppCompat?


When writing an Android library, should I use the AppCompat or Support variants provided by the support library?

For example, should a method take an Activity or an AppCompatActivity? support.v4.Fragment or android.app.Fragment?


Solution

  • In general you should use the AppCompat libraries wherever possible. The library provides backporting for some new features (whatever is practical), and fixes bugs in various version specific versions. For Activities and Fragments its particularly important, as Fragments at least had major differences between versions.