I am trying to run 2 activities on 2 different processes. The purpose of doing this is that my app is displaying my product which adds homescreen icons of my subproducts. Whenever i am using the main product, i want it to be displayed on the main process while my sub product to be displayed in a different activity on another process. This is so that when exiting a subproduct, resuming my main product can be fast because its already running in the background.
Reading through this:
http://developer.android.com/guide/topics/manifest/activity-element.html#proc
They state that you can separate activities into different processes using android:process attribute. Here’s what i’ve done:
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true" android:process="com.mypackage.myapp">
<activity android:name=".ProductActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name=".SubProductActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
android:process=":com.mypackage.myapp.newprocname">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
</activity>
<activity android:name="com.phonegap.DroidGap" android:label="@string/app_name" android:configChanges="orientation|keyboardHidden"> <intent-filter> </intent-filter> </activity>
</application>
However, logging the current PID, both activites are actually running on the same process…
What can be the problem?
After setting the intent of the subactivity to android.intent.category.LAUNCHER (as you correctly did), set a separate TaskAffinity string for the second activity.
E.g. in the second activity line in the manifest make sure you have something similar to
This tells Android to run the SubProductActivity in a separate process.
Refer also to https://stackoverflow.com/a/3270422/978329