salezica
salezica

Reputation: 77099

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?

Upvotes: 0

Views: 75

Answers (2)

hjchin
hjchin

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.

enter image description here

android.app.Fragment has been deprecated now with API 28. So just go for the support Fragment version.

Upvotes: 0

Gabe Sechan
Gabe Sechan

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

Related Questions