SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
Android platform




              Activity




                         Cao Minh Vu
                                             1
                         cmv.ict@gmail.com
Outline

   What is activity
   Starting activity
   Shutting down activity
   Activity lifecycle
   Save state
   Back stack
   Tips

                             2
What is activity

   An application component
       A screen with which user can interact
       A window to draw its UI




                                                3
Creating an activity

   Declare in manifest.xml
   Implement xml layout (optional)
   Extends from Activity




                                      4
Starting an activity


   By name
      Intent intent = new Intent(this, SignInActivity.class);
      startActivity(intent);
   By action
      Intent intent = new Intent(“com.multi.action_show”);
      startActivity(intent);



                                                                5
Starting an activity (cont)

   Start for result
      Intent intent = new Intent((Intent.ACTION_PICK);
      intent.setType(“video/*”);
      startActivityForResult(intent, requestCode);


      protected void onActivityResult(int requestCode, int
      resultCode, Intent data) {
      }


                                                             6
Shutting down an activity

   Explicitly
       Finish();
   Implicitly
       Let the system do it (when user press BACK HW)
   Force Close




                                                         7
Activity lifecycle

   onCreate(Bundle savedInstanceState)
       initialize the essential components
       setContentView();
   onResume()
       just before the activity starts interacting with the
        user (foreground)
   OnPause()
       Another activity is in the foreground + focus, but this
        one is still visible => completely alive
       partially transparent or doesn't cover the entire      8
        screen
Activity lifecycle (cont)

   OnStop()
       completely obscured by another activity
        (=>background)
       is not attached to the window manager




                                                  9
Activity lifecycle (cont)




                            10
Save state




             11
Back stack

   Android Manifest
       "standard" (the default mode)
       "singleTop"
       "singleTask"
       "singleInstance"
   Flag
       FLAG_ACTIVITY_NEW_TASK (single task)
       FLAG_ACTIVITY_SINGLE_TOP (single top)
       FLAG_ACTIVITY_CLEAR_TOP
                                                12
Configuration change

   Screen orientation, change language...
       Call onDestroy and onCreate()
       Avoid ?
        <activity android:name=".CustomGalleryActivity"
           android:configChanges="keyboardHidden|
        orientation"/>




                                                          13
Homework
   Given activities started in order: A->B-C->D
    Draw the back stack to illustrate 2 cases:
       1. Start new activity D
       2. Start new activity B
    with modes: standard, singleTop, singleTask,
    singleInstance and Flag:
    FLAG_ACTIVITY_NEW_TASK,
    FLAG_ACTIVITY_SINGLE_TOP,
    FLAG_ACTIVITY_CLEAR_TOP
        Requirement:
       Draw back stack state when start new activity and
                                                            14
        then press back HW until the program is closed
Tips




       15
Reference

   http://developer.android.com/guide/topics/funda
    mentals/activities.html




                                                  16

Weitere Àhnliche Inhalte

Andere mochten auch

よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹
よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹ă‚ˆă“ăžăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹
よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹Yuichiro Suzuki
 
The agile pmp teaching an old dog new tricks
The agile pmp teaching an old dog new tricksThe agile pmp teaching an old dog new tricks
The agile pmp teaching an old dog new tricksLong Thay
 
Satire presentation
Satire presentationSatire presentation
Satire presentationmsmith94
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgetsHoang Vy Nguyen
 
Android platform overview
Android platform overviewAndroid platform overview
Android platform overviewHoang Vy Nguyen
 
Web Mashup Slides For Lesson 1
Web Mashup Slides For Lesson 1Web Mashup Slides For Lesson 1
Web Mashup Slides For Lesson 1Alvin Chua
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgetsHoang Vy Nguyen
 
Web Mashup Slides For Lesson 2
Web Mashup Slides For Lesson 2Web Mashup Slides For Lesson 2
Web Mashup Slides For Lesson 2Alvin Chua
 
Cheatsheet
CheatsheetCheatsheet
Cheatsheetbvaz
 
Android platform broadcast_receiver_intent
Android platform broadcast_receiver_intentAndroid platform broadcast_receiver_intent
Android platform broadcast_receiver_intentHoang Vy Nguyen
 
Shining Bright Blue In A Sea Of Green
Shining Bright Blue In A Sea Of GreenShining Bright Blue In A Sea Of Green
Shining Bright Blue In A Sea Of GreenDerek Oliver, PMP
 
Adapter and cache technique
Adapter and cache techniqueAdapter and cache technique
Adapter and cache techniqueHoang Vy Nguyen
 
Change Management
Change ManagementChange Management
Change ManagementGENPACT
 
Cheatsheet
CheatsheetCheatsheet
Cheatsheetbvaz
 

Andere mochten auch (16)

よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹
よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹ă‚ˆă“ăžăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹
よこまăȘ3 15ç™șèĄšèł‡æ–™ æœ€èż‘ViewController をどんăȘæ„Ÿă˜ă§æ›žă„ăŠă„ă‚‹ă‹
 
The agile pmp teaching an old dog new tricks
The agile pmp teaching an old dog new tricksThe agile pmp teaching an old dog new tricks
The agile pmp teaching an old dog new tricks
 
Arisnb corel-draw
Arisnb corel-drawArisnb corel-draw
Arisnb corel-draw
 
Satire presentation
Satire presentationSatire presentation
Satire presentation
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgets
 
Android platform overview
Android platform overviewAndroid platform overview
Android platform overview
 
Bulimia
BulimiaBulimia
Bulimia
 
Web Mashup Slides For Lesson 1
Web Mashup Slides For Lesson 1Web Mashup Slides For Lesson 1
Web Mashup Slides For Lesson 1
 
Android platform widgets
Android platform widgetsAndroid platform widgets
Android platform widgets
 
Web Mashup Slides For Lesson 2
Web Mashup Slides For Lesson 2Web Mashup Slides For Lesson 2
Web Mashup Slides For Lesson 2
 
Cheatsheet
CheatsheetCheatsheet
Cheatsheet
 
Android platform broadcast_receiver_intent
Android platform broadcast_receiver_intentAndroid platform broadcast_receiver_intent
Android platform broadcast_receiver_intent
 
Shining Bright Blue In A Sea Of Green
Shining Bright Blue In A Sea Of GreenShining Bright Blue In A Sea Of Green
Shining Bright Blue In A Sea Of Green
 
Adapter and cache technique
Adapter and cache techniqueAdapter and cache technique
Adapter and cache technique
 
Change Management
Change ManagementChange Management
Change Management
 
Cheatsheet
CheatsheetCheatsheet
Cheatsheet
 

Ähnlich wie Android platform activity

Activity
ActivityActivity
ActivityNikithaNag
 
Activity
ActivityActivity
ActivityNikithaNag
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic ComponentsJussi Pohjolainen
 
Android development - Activities, Views & Intents
Android development - Activities, Views & IntentsAndroid development - Activities, Views & Intents
Android development - Activities, Views & IntentsLope Emano
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)TECOS
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Gabor Varadi
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)Oum Saokosal
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2DHIRAJ PRAVIN
 
Activities.pptx
Activities.pptxActivities.pptx
Activities.pptxmahamaalej3
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android DevelopmentJussi Pohjolainen
 
Android N multi window
Android N multi windowAndroid N multi window
Android N multi windowYu-Wei Chuang
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsVIA Embedded
 
Pertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptxPertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptxMUHAMMADRIFKIPERMANA2
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycleSokngim Sa
 
android activity
android activityandroid activity
android activityDeepa Rani
 

Ähnlich wie Android platform activity (20)

Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Activity
ActivityActivity
Activity
 
Android Basic Components
Android Basic ComponentsAndroid Basic Components
Android Basic Components
 
Android development - Activities, Views & Intents
Android development - Activities, Views & IntentsAndroid development - Activities, Views & Intents
Android development - Activities, Views & Intents
 
Mobile application development: part 1: Andriod Vs IOS
Mobile application development: part 1: Andriod Vs IOS Mobile application development: part 1: Andriod Vs IOS
Mobile application development: part 1: Andriod Vs IOS
 
02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)02 programmation mobile - android - (activity, view, fragment)
02 programmation mobile - android - (activity, view, fragment)
 
Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)Architecting Single Activity Applications (With or Without Fragments)
Architecting Single Activity Applications (With or Without Fragments)
 
08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)08.1. Android How to Use Intent (explicit)
08.1. Android How to Use Intent (explicit)
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Android development Training Programme Day 2
Android development Training Programme Day 2Android development Training Programme Day 2
Android development Training Programme Day 2
 
Introduction toandroid
Introduction toandroidIntroduction toandroid
Introduction toandroid
 
Activities.pptx
Activities.pptxActivities.pptx
Activities.pptx
 
Quick Intro to Android Development
Quick Intro to Android DevelopmentQuick Intro to Android Development
Quick Intro to Android Development
 
Android N multi window
Android N multi windowAndroid N multi window
Android N multi window
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded Applications
 
Pertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptxPertemuan 03 - Activities and intents.pptx
Pertemuan 03 - Activities and intents.pptx
 
04 activities and activity life cycle
04 activities and activity life cycle04 activities and activity life cycle
04 activities and activity life cycle
 
android activity
android activityandroid activity
android activity
 

KĂŒrzlich hochgeladen

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 

KĂŒrzlich hochgeladen (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 

Android platform activity

  • 1. Android platform Activity Cao Minh Vu 1 cmv.ict@gmail.com
  • 2. Outline  What is activity  Starting activity  Shutting down activity  Activity lifecycle  Save state  Back stack  Tips 2
  • 3. What is activity  An application component  A screen with which user can interact  A window to draw its UI 3
  • 4. Creating an activity  Declare in manifest.xml  Implement xml layout (optional)  Extends from Activity 4
  • 5. Starting an activity  By name Intent intent = new Intent(this, SignInActivity.class); startActivity(intent);  By action Intent intent = new Intent(“com.multi.action_show”); startActivity(intent); 5
  • 6. Starting an activity (cont)  Start for result Intent intent = new Intent((Intent.ACTION_PICK); intent.setType(“video/*”); startActivityForResult(intent, requestCode); protected void onActivityResult(int requestCode, int resultCode, Intent data) { } 6
  • 7. Shutting down an activity  Explicitly  Finish();  Implicitly  Let the system do it (when user press BACK HW)  Force Close 7
  • 8. Activity lifecycle  onCreate(Bundle savedInstanceState)  initialize the essential components  setContentView();  onResume()  just before the activity starts interacting with the user (foreground)  OnPause()  Another activity is in the foreground + focus, but this one is still visible => completely alive  partially transparent or doesn't cover the entire 8 screen
  • 9. Activity lifecycle (cont)  OnStop()  completely obscured by another activity (=>background)  is not attached to the window manager 9
  • 12. Back stack  Android Manifest  "standard" (the default mode)  "singleTop"  "singleTask"  "singleInstance"  Flag  FLAG_ACTIVITY_NEW_TASK (single task)  FLAG_ACTIVITY_SINGLE_TOP (single top)  FLAG_ACTIVITY_CLEAR_TOP 12
  • 13. Configuration change  Screen orientation, change language...  Call onDestroy and onCreate()  Avoid ? <activity android:name=".CustomGalleryActivity" android:configChanges="keyboardHidden| orientation"/> 13
  • 14. Homework  Given activities started in order: A->B-C->D Draw the back stack to illustrate 2 cases:  1. Start new activity D  2. Start new activity B with modes: standard, singleTop, singleTask, singleInstance and Flag: FLAG_ACTIVITY_NEW_TASK, FLAG_ACTIVITY_SINGLE_TOP, FLAG_ACTIVITY_CLEAR_TOP Requirement:  Draw back stack state when start new activity and 14 then press back HW until the program is closed
  • 15. Tips 15
  • 16. Reference  http://developer.android.com/guide/topics/funda mentals/activities.html 16