Android application This object may be instantiated multiple times, which occurs when the android:process element is used.
The fundamental reason is that the newly opened process requires a Application Object service 4 large components.
Here is a code to get the name of the current process, through which you can determine whether the master process is running.
/** returns the name of the process and, if it is the main process, the package name*/public static String Getcurprocessname (context context) {int pid = Process.mypid (); Activitymanager Mactivitymanager = (activitymanager) context.getsystemservice ("activity"); Iterator iter = Mactivitymanager.getrunningappprocesses (). iterator (); Runningappprocessinfo Appprocess;do {if (!iter.hasnext ()) {return null;} Appprocess = (runningappprocessinfo) iter.next ();} while (appprocess.pid! = pid); return appprocess.processname;}
Multiple instantiation of Android Application object