Onstart and onstop can be called mulple mes as the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: As an ac'vity transi'ons from state to state, it is no'fied of the change by calls to the following protected methods: void onCreate(Bundle savedInstanceState) void onStart() void onRestart() void onResume() void onPause() void onStop() void onDestroy() COMP 4521 (Muppala) Android Overview 5 Ac'vity Lifecycle Three nested loops for the en're lifecycle –  Visible Life'me •  User can see the ac'vity on- screen, though it may not be in the foreground and interac'ng with the user. •  onStart() and onStop() can be called mul'ple 'mes, as the ac'vity alternates between being visible and hidden to the user. Foreground Life'me •  From onCreate() to onDestroy() •  An ac'vity does all its ini'al setup of "global" state in onCreate() •  releases all remaining resources in onDestroy() •  For example, create that thread in onCreate() and then stop the thread in onDestroy(). Visible Life'me –  En"re life"me En're Life'me •  –  Foreground Life'me •  Ac'vity is in front of all other ac'vi'es on screen and is interac'ng with the user. COMP 4521 (Muppala) Android Overview 6 Ac'vity Lifecycle •  When are the methods called in an ac'vity's overall lifecycle?   onCreate() •  Called when the ac'vity is first created or when the ac'vity was killed –  onStart() •  Called just before the ac'vity becomes visible to user –  onRestart() •  Called aZer the ac'vity has been stopped, just prior to it being started again –  onResume() •  Called just before the ac'vity starts interac'ng with the user •  At this point, the ac'vity is at the top of the ac'vit...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online