Let's assume that there are 3 activities namely ActivityA, ActivityB and ActivityC.
<activity
android:name=".ActivityA" />
<activity
android:name=".ActivityB"
android:process=":process2" />
<activity
android:name=".ActivityC" />
The flow of instantiation of the activities is as follows:
- ActivityA is running in the main application process.
- ActivityA starts ActivityB.
- ActivityB is created and runs in process2 (as the android:process attribute is set for it)
- ActivityB now starts ActivityC.
- ActivityC is created and runs in main application process (defaults to the main process)
Requirement:
Whenever an Android component (Activity, Service etc.) is created from another component in process2, make sure that those components get created and executed in process2 only (even though the android:process for those components are not defined in the manifest file). Eg: In the above case, ActivityC should be enforced to create and run in Process2.
Reasons for the requirement:
- Execution of ActivityB and ActivityC should be sandboxed and any issues due to them should not be affecting the main process. So it is required to execute them in a separate process - process2.
- ActivityC is defined in a 3rd party SDK code. So there is no control over setting the attribute android:process for this activity.
I have searched in various forums and I have not been able to get an answer to this question. Kindly let me know how can this be achieved.