17

I'm a newbie to Android Development. Even though I referred the android developer website, I didn't figure out.

On the customize Activity dialog box, when I unchecked the Backwards Compatiblity(Appcompat) in Android Studio 2.3.1 It gave me a hint as:

If false, this activity base class will be Activity instead of AppCompatActivity

enter image description here

Generally, what do android developers prefer? enabling backwards compatibility or without it? Can anyone explain me which one is better.

coderpc
  • 4,119
  • 6
  • 51
  • 93
  • 3
    See https://stackoverflow.com/a/38963902/115145 and https://stackoverflow.com/a/36989121/115145 for some more background. There is no "better" in the abstract -- you need to define criteria against which one can compare options. – CommonsWare May 04 '17 at 16:26

3 Answers3

20

Android apps can be backward-compatible without checking this checkbox.

If false, this activity base class will be Activity instead of AppCompatActivity

Android studio is letting you know that if you uncheck the "Backwards Compatability(Appcompat)" box, then you'll be including & using the library Activity instead of AppCompatActivity. For a more detailed comparison between the two, check this: Activity, AppCompatActivity, FragmentActivity, and ActionBarActivity: When to Use Which?

Generally, what do android developers prefer? enabling backwards compatibility or without it?

A comment written by "CommonsWare" explains this best:

An activity created with that checkbox checked is no more backwards compatible than is one without that checkbox checked. Checking the checkbox gives your app a particular look and feel that will retain that look and feel on some older devices; leaving the checkbox unchecked means that some aspects of your look and feel will be different on pre-Android 5.0 devices. This does not impact the core functionality of the activity, though. – CommonsWare

Community
  • 1
  • 1
Tomer Dricker
  • 216
  • 1
  • 5
  • 2
    Android apps can be backwards compatible without checking this checkbox. – CommonsWare May 04 '17 at 16:24
  • That's true. But if you check the "Backwards Compatability(Appcompat)" box when creating a project, it builds the project in a way already suited for backward compatibility. – Tomer Dricker May 04 '17 at 16:26
  • 8
    An activity created with that checkbox checked is no more backwards compatible than is one without that checkbox checked. Checking the checkbox gives your app a particular look and feel that will retain that look and feel on some older devices; leaving the checkbox unchecked means that some aspects of your look and feel will be different on pre-Android 5.0 devices. This does not impact the core functionality of the activity, though. – CommonsWare May 04 '17 at 16:29
  • I just checked to make sure, and it seems you are completely right. When I originally studied it, I always thought that it doesn't change the core functionality like you mentioned, but it adds a lot of unnecessary libraries (If you don't care towards backward compatibility) and that is not the case. Thank you for correcting me! – Tomer Dricker May 04 '17 at 16:41
7

Backwards compatibility allows you to use certain backwards compatible features in your app. They will be able to work on previous versions of Android.

The Android Support Library offers backward-compatible versions of a number of features that are not built into the framework. (Android Support Library website)

For example, instead of Activity, AppCompatActivity will be used and is something that is "backwards" compatible. It can be used all the way back to API level 15.

Tristan
  • 3,530
  • 3
  • 30
  • 39
-2

You should generally use AppCompatActivity to support older Android versions. If your app has no need for older android versions, then just use Activity.

Using AppCompatActivity is generally more recommended.

Timmo
  • 2,266
  • 4
  • 34
  • 54
  • As mentioned above, this options affect only how your app looks, you can support older andro versions with "just" `Activity` too. – Qback Dec 24 '17 at 01:31