I am quite new to Android and Android Studio. I have created a new project and I have specified the minSdkVersion as 21
and target to 23
.
After AS is done with creating the activity I see that MainActivity
is extending AppCompatActivity
by default.
I read about AppCompatActivity
here
It says that it is the Base class for activities that use the support library action bar features.
Now my question is:
Why does AS make my activity extend AppCompatActivity by default?
Is it necessary for my activity to extend AppCompatActivity or just extending Activity is enough considering my minSdkVerion
?
What would I miss if my actvity don't extend AppCompatActivity?
Any explanation would be very helpful. Thanks
Extension activities concentrates on putting across in an understandable manner new ideas and improved technologies of practical utility to the rural, tribal and urban privileged and underprivileged people. It enables us to use the newly acquired knowledge and skills to improve their general standard of living.
Extensions provide a means of associating additional attributes with users or public keys and for managing a certification hierarchy. The extension format also allows communities to define private extensions to carry information unique to those communities.
An activity provides the window in which the app draws its UI. This window typically fills the screen, but may be smaller than the screen and float on top of other windows. Generally, one activity implements one screen in an app.
The activity is a Java class, and the layout is an XML file, so the names we've given here will create a Java class file called MainActivity. java and an XML file called activity_main. xml. When you click on the Finish button, Android Studio will build your app.
I think you should extend AppCompatActivity if you are using action bar
Read more here
Beginning with Android 3.0 (API level 11), all activities that use the default theme have an ActionBar as an app bar. However, app bar features have gradually been added to the native ActionBar over various Android releases. As a result, the native ActionBar behaves differently depending on what version of the Android system a device may be using. By contrast, the most recent features are added to the support library's version of Toolbar, and they are available on any device that can use the support library.
For this reason, you should use the support library's Toolbar class to implement your activities' app bars. Using the support library's toolbar helps ensure that your app will have consistent behavior across the widest range of devices. For example, the Toolbar widget provides a material design experience on devices running Android 2.1 (API level 7) or later, but the native action bar doesn't support material design unless the device is running Android 5.0 (API level 21) or later.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With