Code example for ActivityManager

Methods: getRunningAppProcesses

0
  public static AppManager getInstance() { 
    return instance;
  } 
 
  private void refreshList() { 
    processes = activityManager.getRunningAppProcesses();
  } 
 
  public boolean isRunning(String app) {
    refreshList(); 
    for (ActivityManager.RunningAppProcessInfo process : processes) {
      if (process.processName.startsWith(app)) return true;
    } 
    return false; 
  } 
 
  public boolean kill(String app) {
    refreshList(); 
    for (ActivityManager.RunningAppProcessInfo process : processes) {
      if (process.processName.startsWith(app)) {
        activityManager.restartPackage(process.processName);