Bài tập lớn :quản lý tiến trình android

16 502 1
Bài tập lớn :quản lý tiến trình android

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

ANDROI D PROCESS MANAGEMENT BY HOANG VAN KIEN HOANG HUY KHANH PHUNG DUC LUAN ANDROID APPLICATION FUNDAMENTALS PROCESS LIFE CYCLE Application Fundamentals 04:52:53 PM Application Components Android Android is is multi-user multi-user OS, OS, each each application application has has it’s it’s own own user user ID ID (because (because of of security security reasons) reasons) Each Each application application has has it’s it’s own own VM(virtual VM(virtual machine), machine), to to provide provide isolation isolation from from other other process process Each Each application application has has it’s it’s own own process process Application Application is is aa combination combination of of components components APPLICATION PROCESS COMPONENT COMPONENT COMPONENT COMPONENT Application Fundamentals 04:52:53 PM Application Components Activities An activity represents a single screen with a user interface, in-short Activity performs action on the screen Services A service is a component that runs in the background to perform long-running operations A S B C A Broadcast Receivers Broadcast receivers simply respond to broadcast messages from other applications or from the system Content Providers A content provider component supplies data from one application to others on request Other Components There are additional components which will be used in the construction of above mentioned entities Application Fundamentals 04:52:53 PM Application Components First Activity Second Activity Click me! This is second activity Application Fundamentals 04:52:53 PM Application Components Your Your app app can can use use another another app’s app’s components components YOUR APP Use Email app to write email Write Email Get Email Address Use Contacts app to get email address Send Email Use Email app to send email Application Fundamentals 04:52:53 PM Activity Stack Activity Stack Activity Previous Activities Removed to free resources Activity … Activity Activity n-1 Last Running Activity Back button pushed or Running activity closed New Activity Started New Activity Running Activity Application Fundamentals 04:52:53 PM Activity Lifecycle New Activity onCreated() states of an activity onStart() onResume() 1.Active/Running: if the activity is at the foreground 2.Paused: if the activity is at the background and still visible 3.Stopped: if the activity is not visible and therefore is hidden or obscured by another activity 4.Destroyed: when the activity process is killed or completed terminated Running onResume() onPause() Paused onResume() onStart() onStop() onRestart() Stopped onDestroy() Destroyed Application Fundamentals 04:52:53 PM Activity Lifecycle There are lifecycle processes in an Android activity They include − onCreate − It is called when the activity is first created onStart − It is called when the activity starts and becomes visible to the user onResume − It is called when the activity starts interacting with the user User input takes place at this stage onPause − It is called when the activity runs in the background but has not yet been killed onStop − It is called when the activity is no longer visible to the user onRestart − It is called after the activity has stopped, before starting again It is normally called when a user goes back to a previous activity that had been stopped onDestroy − This is the final call before the activity is removed from the memory New Activity onCreated() onStart() onResume() Running onResume() onPause() Paused onResume() onStart() onStop() onRestart() Stopped onDestroy() Destroyed Android Process Lifecycle 04:52:53 PM Android Process For For each each application application android android creates creates aa new new process process with with single single thread thread of of execution(i.e execution(i.e main main thread) thread) By By default default all all the the components components run run in in same same thread(main thread(main thread) thread) In In low low memory memory situations situations aa process process is is decide decide to to kill kill based based upon upon the the number number of of inactive inactive components components of of that that process process AA process process which which have have more more number number of of inactive inactive components components should should be be killed killed first first APPLICATION PROCESS THREAD COMPONENT COMPONENT COMPONENT COMPONENT Android Process Lifecycle 04:52:53 PM Android Process States Process Priority 1.Active Process Active (foreground) processes have application components the user is interacting with: • Activities in an active state • Broadcast Receivers executing onReceive • Services executing onStart, onCreate • Running Services that have been flagged to run in the foreground Active Process Highest Visible Process Service Process Background Process Empty Process Lowest Android Process Lifecycle 04:52:53 PM Android Process States Process Priority Visible Process Visible but inactive processes are those hosting “visible” Activities This happens when an Activity is only partially obscured (by a non-full-screen or transparent Activity) Active Process Highest Visible Process Service Process Background Process Empty Process Lowest Android Process Lifecycle 04:52:53 PM Android Process States Process Priority Service Process Processes hosting Services that have been started Because these Services don’t interact directly with the user, they receive the same priority with visible process Active Process Highest Visible Process Service Process Background Process Empty Process Lowest Android Process Lifecycle 04:52:53 PM Android Process States Process Priority Background Process Processes hosting Activities that aren’t visible and that don’t have any running Services There will generally be a large number of background processes that Android will kill using a last-seen-first-killed pattern in order to obtain resources for foreground processes Active Process Highest Visible Process Service Process Background Process Empty Process Lowest Android Process Lifecycle 04:52:53 PM Android Process States Process Priority Empty Process To improve overall system performance, Android will often retain an application in memory after it has reached the end of its lifetime Android maintains this cache to improve the start-up time of applications when they’re re-launched These processes are routinely killed, as required Active Process Highest Visible Process Service Process Background Process Empty Process Lowest THANKS FOR LISTENING! ... onRestart() Stopped onDestroy() Destroyed Android Process Lifecycle 04:52:53 PM Android Process For For each each application application android android creates creates aa new new process process.. .ANDROID APPLICATION FUNDAMENTALS PROCESS LIFE CYCLE Application Fundamentals 04:52:53 PM Application Components Android Android is is multi-user multi-user... Background Process Empty Process Lowest Android Process Lifecycle 04:52:53 PM Android Process States Process Priority Empty Process To improve overall system performance, Android will often retain an application

Ngày đăng: 15/12/2017, 16:44

Mục lục

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

Tài liệu cùng người dùng

Tài liệu liên quan