public class MainActivity extends AppCompatActivity
public class MainActivity extends Activity
Copy the code
Q: What’s the difference between an AppCompatActivity and an Activity? Android Studio automatically extends AppCompatActivity from starting to creating a MainActivity, why doesn’t it extend Activity?
A: AppCompatActivity is inherited FragmentAvtivity from the V4 package and adds a lot of new features. This works well with older devices.
The difference between AppCompatActivity and Activity mainly shows the interface after the app runs (the app name is displayed or not displayed), which has no impact on the program itself.
First look at the compatactivity interface after inheriting AppCompatActivity.