Packagecom.chy.myapplication;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;/** Support V4 fragmentactivity compatible 2.x mode using fragment* V7 appcompatactivity Compatible with 2.x mode using fragment and actionbar,actionbaractivity are appcompatactivity obsolete products * If more than 3.0 directly inherit activity, you can use fragment and Actionbar*/ Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); }}
After the Activity has developed to 3.0 (presumably), you can use fragment, but support V4 provides 1.6~3.0 fragment compatibility, so if you need to use a compatible version of fragment, you need to inherit V4 provides the fragmentactivity.
After a little bit of time, the 3.0 (presumably) Actionbar is also supported, this time in support V7, if you need to use a compatible version of Actionbar, inherit The actionbaractivity provided by V7 (which is inherited fragmentactivity).
And then the end of last year to this year, 5.0 provides a lot of new things, so support V7 also updated, appeared appcompatactivity, specific features please find out for yourself.
=============================================================================================================== =================================================
The following information is from Googlehttp://stackoverflow.com/questions/31297246/ Activity-appcompatactivity-fragmentactivity-and-actionbaractivity-when-tous
======================================================================================================== ===============================
activity is The base class of all other activities, I don ' t think it'll be deprecated. The relationship among them is:
Activity<<<FragmentActivity<<<AppCompatActivity<<<ActionBarActivity
' <<< ' means inheritance here. The reference saidActionBarActivityis deprecated, useAppCompatActivityinstead.
so Basically, Using appcompatactivity is always the right choise. The differences between them:
Activityis the basic one.
- Based on
Activity,FragmentActivityProvides the ability to useFragment.
- Based on
FragmentActivity,AppCompatActivityProvides features toActionBar
The difference between appcompatactivity, actionbaractivity, fragmentactivity, and activity