How do you get a list of Android applications?



  • I need to get a list of the processes launched and their " state of affairs " (cashed or under way, etc.).

    Maybe. PackageManager and ApplicationInfo Can you get a status just like that? Where to dig?



  • I got an answer.

    // Get running processes
    ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> runningProcesses = manager.getRunningAppProcesses();
    if (runningProcesses != null && runningProcesses.size() > 0) {
        // Set data to the list adapter
        setListAdapter(new ListAdapter(this, runningProcesses));
    } else {
        // In case there are no processes running (not a chance :))
        Toast.makeText(getApplicationContext(), "No application is running", Toast.LENGTH_LONG).show();
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2