Reputation: 77099
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
?
Upvotes: 0
Views: 75
Reputation: 874
AppCompatActivity is the base class that support Support library ActionBar while Activity is actually the parent of AppCompatActivity. Depending on your purpose of library, if you have no intention of using the Support library ActionBar / Fragment related feature in your library, I would say, in general, the activity class is sufficient for your library.
android.app.Fragment has been deprecated now with API 28. So just go for the support Fragment version.
Upvotes: 0
Reputation: 93708
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.
Upvotes: 1