Issue
I am trying to understand the activity startup in Android System Server. What is the flow when we use the statement startActivity(intent); in our code and the onCreate() of the activity is executed.I know flow after onCreate().
Something happens on the framework side of the Android, what is it?
Solution
The click event gets translated into startActivity(intent) call which gets routed to startActivity(intent) call in ActivityManagerService through Binder IPC. The ActvityManagerService takes couple of actions -
- The first step is to collect information about the target of the intent object. This is done by using
resolveIntent()
method onPackageManager object
.PackageManager.MATCH_DEFAULT_ONLY and PackageManager.GET_SHARED_LIBRARY_FILES flags are used by default. - The target information is saved back into the intent object to avoid re-doing this step.
- Next important step is to check if user has enough privileges to invoke the target component of the intent. This is done by calling
grantUriPermissionLocked()
method. - If user has enough permissions,
ActivityManagerService
checks if the target activity requires to be launched in a new task. The task creation depends on Intent flags such asFLAG_ACTIVITY_NEW_TASK
and other flags such asFLAG_ACTIVITY_CLEAR_TOP
. - Now, it's the time to check if the
ProcessRecord
already exists for the process. - If no record exists, we create a new process record. The file Process.java is mainly responsible to fork a call in Zygote which returns a new process id.
- After all this is completed, the final native method is called which in turn calls the onCreate method of the activity.
Hope this solves your query.
Answered By - nikoo28
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.