1 / 11

Programming with Android: Activities

Programming with Android: Activities. Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna. Activity. Outline: What is started by the device It contains the application's informations Has method to answer certain events

karena
Télécharger la présentation

Programming with Android: Activities

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming with Android: Activities Luca Bedogni Marco Di Felice Dipartimento di Scienze dell’Informazione Università di Bologna

  2. 2 Activity Outline: What is started by the device It contains the application's informations Has method to answer certain events An application could be composed of multiple activities

  3. 3 Creating an activity Create a class that is a subclass of Activity Implement callback methods OnCreate(): Initialize SetContentView()

  4. 4 Activity lifecycle

  5. 5 Activity lifecycle OnCreate() Called when the activity is created Should contain the initialization operations Has a Bundle parameter If onCreate() succesfull terminates, it calls onStart()

  6. 6 Activity lifecycle OnStart() Called when onCreate() terminates Called right before it is visible to user If it has the focus, then onResume() is called If not, onStop() is called

  7. 7 Activity lifecycle OnResume() Called when the activity is ready to get input from users Called when the activity is resumed too If it succesfully terminates, then the Activity is RUNNING

  8. 8 Activity lifecycle OnPause() Called when another activity comes to the foreground, or when someone presses back Commit unsaved changes to persistent data Stop cpu-consuming processes Make it fast

  9. 9 Activity lifecycle OnRestart() Similar to onCreate() We have an activity that was previously stopped

  10. 10 Activity lifecycle OnStop() Activity is no longer visible to the user Could be called because: the activity is about to be destroyed another activity comes to the foreground

  11. 11 Activity lifecycle OnDestroy() The activity is about to be destroyed Could happen because: The systems need some stack space Someone called finish() method on this activity Could check with isFinishing()

More Related