Difference between Activity and AppCompatActivity

Activity is the fundamental block of creating Android Application.
 Activity is the base Class of all other Activities.

Activity - fragmentactivity - AppCompatActivity - ActionBarActivity

means, AppCompatActivity inherits FragmentActivity and FragmentActivity inherent Activity.

in the Android Developer Documentation :


For more read from Android developer Documentation :
Activity | Android Developer


AppCompatActivity
If you want to add ActionBar in the Activity when Android Application running API Level 7 or Higher by extending the class of the Activity.


AppCompatActivity hierarchy :



To use the AppCompatActivity, make sure you have the Google Support Library downloaded (you can check this in your Tools -> Android -> SDK manager). Then just include the gradle dependency in your app's gradle.build file :


compile 'com.android.support:appcompat-v7:26.0.0-alpha1'

For More read from Android Developer Documentation :
 AppCompatActivity | Android developers

FragmentActivity
The implementation of Fragment is comes with API Level 11.
specifically, if you want to use nested fragments (a fragment holding another fragment), as that was not supported in native fragments until API Level 17.


So, given your minSdkVersion in the 15-16 range:

  •   If you want the backported Material Design look, use AppCompatActivity
  •  If not, but you want nested fragments, use FragmentActivity
  •  If not, use Activity

For more read from Android Developer Documentation :
FragmentActivity | Android Developers

 



Comments

Total Pageviews

6,808