/**get the launcher status */
private boolean isLauncherRunnig(Context context) {
boolean result = false ;
List<String> names = getAllTheLauncher();
ActivityManager mActivityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE) ;
List<ActivityManager.RunningAppProcessInfo> appList = mActivityManager.getRunningAppProcesses() ;
for (RunningAppProcessInfo running : appList) {
if (running.importance == RunningAppProcessInfo.IMPORTANCE_FOREGROUND) {
for (int i = 0; i < names.size(); i++) {
if (names.get(i).equals(running.processName)) {
result = true ;
break;
}
}
}
}
return result ;
}
private List<String> getAllTheLauncher(){
List<String> names = null;
PackageManager pkgMgt = this.getPackageManager();
Intent it = new Intent(Intent.ACTION_MAIN);
it.addCategory(Intent.CATEGORY_HOME);
List<ResolveInfo> ra =pkgMgt.queryIntentActivities(it,0);
if(ra.size() != 0){
names = new ArrayList<String>();
}
for(int i=0;i< ra.size();i++)
{
String packageName = ra.get(i).activityInfo.packageName;
names.add(packageName);
}
return names;
}