Download presentation
Presentation is loading. Please wait.
Published byDaniel Carroll Modified over 9 years ago
1
Android Activities 1
2
What are Android Activities? Activities are like windows in an Android application An application can have any number of activities Main purpose of an activity is to interact with the user Using Intents you can go from on Activity to another – More on Intents later 2Android Activities
3
Programming an Activity To program an Activity you must create a Java class extending the class android.app.Activity You probably want to override the method onCreate() public class MyActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } 3Android Activities
4
Describing activities in the AndroidManifest.xml file When you create a new Activity, the Activity is described in the AndroidManifest.xml file. Each application has a single AndriodManifest.xml file Describing all the activities And a lot of other things … Android Studio – App -> src -> main -> AndroidManifest.xml 4Android Activities
5
Activity life cycle 5Android Activities
6
Life cycle methods An Activity object goes through quite an elaborate life cycle. The Activity class defines a number of methods which are called when an object goes from one stage to another in the life cycle – Example: LifecycleDemo We can override the methods in our own Activity class – Template Method design pattern Super class is concrete (not abstract) with lots of hook methods Android Activities6
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.