Slide 1

Slide 1 text

Android  Activities  101  

Slide 2

Slide 2 text

Mustafa  Ali   Senior  Android  Engineer,  Technical  Lead         Building  apps  since  v1.6  came  out   MS  from  IIIT  Hyderabad   Who  am  I?  

Slide 3

Slide 3 text

What  about  you?  

Slide 4

Slide 4 text

*  Activity  basics   *  Creating  simple  user  interfaces   *  Activity  lifecycle   *  Passing  data  between  activities   *  Navigating  between  activities   *  Supporting  multiple  orientations  and  locales     Agenda  

Slide 5

Slide 5 text

*  Application  component  that  provides  a  screen  with   which  users  can  interact   *  Each  activity  is  given  a  window  to  draw  its  user   interface   *  Navigating  between  activities  is  managed  by  the   “Back  Stack”   *  Activities  can  send  and  receive  data  to  and  from  other   activities   Activity  Basics  

Slide 6

Slide 6 text

*  Action  Bar   *  Layouts   *  Input  Controls   Creating  user  interfaces  

Slide 7

Slide 7 text

*  Action  Bar   *  Layouts   *  Input  Controls   Creating  user  interfaces  

Slide 8

Slide 8 text

Action  Bar  

Slide 9

Slide 9 text

Action  Bar  

Slide 10

Slide 10 text

*  Dedicated  piece  of  real  estate  at  the  top  of  each   screen  that  is  generally  persistent  throughout  the  app   *  Provides  user  actions  and  navigation  modes   *  Provides  consistent  navigation  across  different   applications   *  Makes  key  actions  for  the  activity  prominent  and   accessible  to  the  user  in  a  predictable  way   Action  Bar  

Slide 11

Slide 11 text

*  Introduced  in  Android  3.0  (API  level  11)   *  Included  automatically  in  all  activities  that  use  the   Theme.Holo  or  one  of  its  descendants   *  Use  the  Android  Compatibility  Library  to  support   older  versions   *  Can  also  use  ActionBarSherlock   Action  Bar  

Slide 12

Slide 12 text

*  Action  Bar   *  Layouts   *  Widgets   Creating  user  interfaces  

Slide 13

Slide 13 text

*  Define  the  visual  structure  for  a  user  interface   *  Can  be  declared  in  XML   *  Can  also  be  created  programmatically   *  Commonly  used  layouts     *  Linear  Layout   *  Relative  Layout   Layouts  

Slide 14

Slide 14 text

*  Action  Bar   *  Layouts   *  Input  Controls   Creating  user  interfaces  

Slide 15

Slide 15 text

Input  Controls  

Slide 16

Slide 16 text

*  Button   *  Text  field   *  Checkbox   *  Radio  button   *  Toggle  button   *  Spinner   *  Pickers   Input  Controls  

Slide 17

Slide 17 text

Activity  lifecycle  

Slide 18

Slide 18 text

Activity  lifecycle  

Slide 19

Slide 19 text

*  Primitive  types     *  Can  be  passed  easily  using  intent  extras   *  Custom  types   *  Can  be  passed  using  the  Parcelable  interface   Passing  data  between  activities  

Slide 20

Slide 20 text

*  Custom  types   1.  Implement  android.os.Parcelable 2.  Override  writeToParcel(…) 3.  Create  a  CREATOR Passing  data  between  Activities  

Slide 21

Slide 21 text

*  Starting  one  activity  from  another   *  startActivity(…) *  Starting  an  activity  for  result   *  startActivityForResult(…) Navigating  between  Activities  

Slide 22

Slide 22 text

*  Android  automatically  adapts  your  layout  for  you   *  Gives  you  the  flexibility  to  have  a  different  layouts  as   well   1.  Create  a  folder  layout-­‐land   2.  Name  of  the  layout  file  should  be  the  same   3.  Ids  of  the  views  in  the  layout  files  should  be  the  same   Supporting  multiple  orientations  

Slide 23

Slide 23 text

*  Important  when  you  audience  is  spread  across   multiple  locations   *  Use  Resource-­‐Switching   Supporting  multiple  locales  

Slide 24

Slide 24 text

Questions?  

Slide 25

Slide 25 text

*  Android  resources  -­‐  developer.android.com   *  StackOverflow.com   *  Hydroid  community  on  G+   Get  in  touch!              profiles.google.com/mustafa01ali              @CodeTweetRepeat   Need  help?  

Slide 26

Slide 26 text

Happy  Coding!