String currentProcessName = getCurrentProcessName();
if (getPackageName().equals(currentProcessName)) {
onAppCreate();
}
//得到当前进程名
private StringgetCurrentProcessName() {
String currentProcName ="";
int pid = android.os.Process.myPid();
ActivityManager manager = (ActivityManager)this.getSystemService(Context.ACTIVITY_SERVICE);
for (ActivityManager.RunningAppProcessInfo processInfo : manager.getRunningAppProcesses()) {
if (processInfo.pid == pid) {
currentProcName = processInfo.processName;
break;
}
}
return currentProcName;
}