mobile computing · user navigates back to the activity. process is killed. other applications need...

16
Mobile Computing LECTURE # 3

Upload: others

Post on 30-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Mobile ComputingLECTURE # 3

Page 2: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

The CourseCourse Code: IT-4545

Course Title: Mobile Computing

Instructor: JAWAD AHMAD◦ Email Address: [email protected]

Web Address: http://csandituoslahore.weebly.com/mc.html

Term (Semester): Spring 2018

Duration: 15/16 Weeks

Page 3: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Activity and its life cycle

Page 4: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

What is an Activity?

• Activity is a window that contains GUI.

• An Application can have 1or more Activities.

• Android Applications normally have several

Activities.

• Several Activities together make an

Application.

• User interacts with Activity.

• Activities are built independent of each other.

Page 5: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Activity Life Cycle

Page 6: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

How Activity Life Cycle Works?

Page 7: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnCreate() Event

• Called when Activity is created

• Normally all the initialization are done in this method

Page 8: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnStart() Event

• Called when Activity is becoming visible to the User

Page 9: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnRestart() Event

• Called when Activity is stopped and restarting

Page 10: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnResume() Event

• Called when Activity is available for interacting

• Called when Activity is in the foreground

Page 11: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnPause() Event

• Called when System is about to resume some other activity

• Called when System is about to start another activity

Page 12: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnStop() Event

• Called when Activity is no longer visible to User

Page 13: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

OnDestroy() Event

• Final call before the Activity is destroyed

• Activity can be destroyed manually by user or Automatically by System

Page 14: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Android Activities work in Stack

Page 15: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Switching Between Activities

Page 16: Mobile Computing · User navigates back to the activity. Process is killed. Other applications need memory. Activity starts. onCreate() onStart() onResume() Activity is running

Switching Between Activities