Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Multiple Activity and Navigation Primer


Published on

Published in: Education, Technology, Travel
  • Login to see the comments

Multiple Activity and Navigation Primer

  1. 1. Android Application Development Being Active Through Activities & Intents Ahsanul Karim [email_address] Sentinel Solutions Ltd.
  2. 2. Today We’re Covering… <ul><li>Application Structure </li></ul><ul><li>Android Application Anatomy </li></ul><ul><li>Activity </li></ul><ul><li>Layout </li></ul><ul><li>Using Layouts from Activity </li></ul><ul><li>Activity to Activity Transition </li></ul><ul><li>Activity Lifecycle </li></ul><ul><li>Exercise </li></ul>
  3. 3. Android Activities Activity Activity provides a user generally with an interactive screen to do something like: Dialing the phone, View a map List of something for user to select or Anything you want your user to do <ul><li>An application usually consists of multiple activities. </li></ul><ul><li>Typically, one activity in an application is specified as the &quot; main &quot; activity, which is presented to the user when launching the application for the first time. (which is specified in AndroidMenifest.xml )  </li></ul>The   <action>  element specifies that this is the &quot;main&quot; entry point to the application. The  <category>  element specifies that this activity should be listed in the system's application launcher (to allow users to launch this activity).
  4. 4. Android Activities (Contd..) Creating Activity We have already created Activities. But how did we create it? Let’s revisit… <ul><li>We created subclass of Activity base class </li></ul><ul><li>We implemented one callback method onCreate </li></ul><ul><li>What is creating subclass??? </li></ul><ul><li>What is callback methods??? </li></ul>Open Questions:
  5. 5. Android Activities (Contd..) Next Step: Implementing User Interface <ul><li>Design res/layout/yourlayout.xml </li></ul><ul><li>Use Views from Activity class </li></ul>Next Step: Implementing User Interface <manifest ... >   <application ... >       <activity android:name=&quot;.ExampleActivity&quot; />       ...   </application ... >   ... </manifest > Next Step: Starting Activity Intent intent = new Intent(this, ToActivity.class); startActivity(intent); We can start another activity by calling  startActivity() , passing it an  Intent  that describes the activity you want to start.
  6. 6. Android Activities Exercise <ul><li>We’ll make 2 Activities </li></ul><ul><li>Registration with basic features and validation: </li></ul><ul><ul><li>Email address </li></ul></ul><ul><ul><li>First Name, Last Name </li></ul></ul><ul><ul><li>Date of Birth </li></ul></ul><ul><ul><li>Password </li></ul></ul><ul><ul><li>Confirm Password </li></ul></ul><ul><ul><li>I agree to terms and conditions </li></ul></ul><ul><ul><li>Buttons: Cancel, Submit </li></ul></ul><ul><li>Login </li></ul><ul><ul><li>Email address </li></ul></ul><ul><ul><li>Password </li></ul></ul><ul><ul><li>Buttons: New User, Login </li></ul></ul><ul><ul><li>(To be added: Remember me) </li></ul></ul><ul><ul><li>Link: </li></ul></ul>
  7. 7. Android Activities Exercise (Contd.) <ul><li>How to add new Activities to the application </li></ul><ul><li>How to navigate from one Activity to another </li></ul>How to navigate from one Activity to another Intent Intent intent_1_to_2 = new Intent(this, Activity2.class); startActivity(intent_1_to_2); Intent Intent intent_2_to_1 = new Intent(this, Activity1.class); startActivity(intent_2_to_1);
  8. 8. Android Activities Exercise (Contd.) How to navigate from one Activity to another Intent Intent intent1to2 = new Intent(this, Activity2.class); startActivity(intent1to2); Intent Intent intent2to1 = new Intent(this, Activity1.class); startActivity(intent2to1);
  9. 9. Activity Lifecycle
  10. 10. Activity Lifecycle (Contd.)