I have an Android app that extends the Application
class and has many app components (services, activities and broadcast receivers) running along three different process.
Each process will instantiate the Application
class as soon as it is started. So I've been looking for how can I check inside the Application
class code, if the instance is owned by the main app process but I have not been able to find it anything.
My manifest looks like this:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".MyApplication"
android:theme="@style/AppTheme" >
<activity
android:name="...">
...
</activity>
<activity
android:name="...">
...
</activity>
<service android:name="..." >
</service>
<service android:name="..."
android:process=":SecondProcess" >
</service>
<service android:name="..."
android:process=":ThirdProcess" >
</service>
Next is my Application
class implementation:
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
if (is this instance being ran on the main process?) {
// Do something
}
}
}
Does anyone know how to check if the instance is running on the main process?