java - Android - Detecting Application class running on main process on a multiprocess app -
i have android app extends application
class , has many app components (services, activities , broadcast receivers) running along 3 different process.
each process instantiate application
class started. i've been looking how can check inside application
class code, if instance owned main app process have not been able find anything.
my manifest looks 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 application
class implementation:
public class myapplication extends application { @override public void oncreate() { super.oncreate(); if (is instance being ran on main process?) { // } } }
does know how check if instance running on main process?
looking answer same question.
so far found use can find current running process process id , put if check in oncreate.
public void oncreate(){ ... string processname = getprocessname(); switch(processname){ case process1: // break; case process2: // break; .... }
Comments
Post a Comment