Codota Logo
AndroidProcesses
Code IndexAdd Codota to your IDE (free)

How to use
AndroidProcesses
in
com.jaredrummler.android.processes

Best Java code snippets using com.jaredrummler.android.processes.AndroidProcesses (Showing top 14 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: jaredrummler/AndroidProcesses

@Override protected List<AndroidAppProcess> doInBackground(Void... params) {
 List<AndroidAppProcess> processes = AndroidProcesses.getRunningAppProcesses();
 // sort by app name
 Collections.sort(processes, new Comparator<AndroidAppProcess>() {
  @Override public int compare(AndroidAppProcess lhs, AndroidAppProcess rhs) {
   return Utils.getName(context, lhs).compareToIgnoreCase(Utils.getName(context, rhs));
  }
 });
 return processes;
}
origin: jaredrummler/AndroidProcesses

/**
 * @return {@code true} if this process is in the foreground.
 */
public static boolean isMyProcessInTheForeground() {
 try {
  return new AndroidAppProcess(android.os.Process.myPid()).foreground;
 } catch (Exception e) {
  log(e, "Error finding our own process");
 }
 return false;
}
origin: AntonioRedondo/AnotherMonitor

if (Build.VERSION.SDK_INT < 22) { // http://stackoverflow.com/questions/30619349/android-5-1-1-and-above-getrunningappprocesses-returns-my-application-packag
  runningAppProcesses = ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).getRunningAppProcesses();
} else runningAppProcesses = AndroidProcesses.getRunningAppProcessInfo(this);
origin: jaredrummler/AndroidProcesses

@Override public void onCreate() {
 super.onCreate();
 AndroidProcesses.setLoggingEnabled(true);
 Picasso.setSingletonInstance(new Picasso.Builder(this)
   .addRequestHandler(new AppIconRequestHandler(this))
   .build());
}
origin: towavephone/MemoryCleaner

beforeMemory = memoryInfo.availMem;
List<ActivityManager.RunningAppProcessInfo> appProcessList
    = AndroidProcesses.getRunningAppProcessInfo(mContext);
ApplicationInfo appInfo = null;
for (ActivityManager.RunningAppProcessInfo info : appProcessList) {
origin: jaredrummler/AndroidProcesses

List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
List<RunningAppProcessInfo> appProcessInfos = new ArrayList<>();
for (AndroidAppProcess process : runningAppProcesses) {
origin: towavephone/MemoryCleaner

    = AndroidProcesses.getRunningAppProcessInfo(mContext);
publishProgress(0, appProcessList.size(), 0, "开始扫描");
origin: jaredrummler/AndroidProcesses

/**
 * @return a list of <i>all</i> processes running on the device.
 */
public static List<AndroidProcess> getRunningProcesses() {
 List<AndroidProcess> processes = new ArrayList<>();
 File[] files = new File("/proc").listFiles();
 for (File file : files) {
  if (file.isDirectory()) {
   int pid;
   try {
    pid = Integer.parseInt(file.getName());
   } catch (NumberFormatException e) {
    continue;
   }
   try {
    processes.add(new AndroidProcess(pid));
   } catch (IOException e) {
    log(e, "Error reading from /proc/%d.", pid);
    // System apps will not be readable on Android 5.0+ if SELinux is enforcing.
    // You will need root access or an elevated SELinux context to read all files under /proc.
   }
  }
 }
 return processes;
}
origin: gigabytedevelopers/FireFiles

List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
for (AndroidAppProcess process : runningAppProcesses) {
  RunningAppProcessInfo info = new RunningAppProcessInfo(
origin: jaredrummler/AndroidProcesses

/**
 * @return a list of all running app processes on the device.
 */
public static List<AndroidAppProcess> getRunningAppProcesses() {
 List<AndroidAppProcess> processes = new ArrayList<>();
 File[] files = new File("/proc").listFiles();
 for (File file : files) {
  if (file.isDirectory()) {
   int pid;
   try {
    pid = Integer.parseInt(file.getName());
   } catch (NumberFormatException e) {
    continue;
   }
   try {
    processes.add(new AndroidAppProcess(pid));
   } catch (AndroidAppProcess.NotAndroidAppProcessException ignored) {
   } catch (IOException e) {
    log(e, "Error reading from /proc/%d.", pid);
    // System apps will not be readable on Android 5.0+ if SELinux is enforcing.
    // You will need root access or an elevated SELinux context to read all files under /proc.
   }
  }
 }
 return processes;
}
origin: ittianyu/MobileGuard

PackageManager pm = context.getPackageManager();
List<AndroidAppProcess> processes = AndroidProcesses.getRunningAppProcesses();
origin: jaredrummler/AndroidProcesses

log(e, "Error reading from /proc/%d.", pid);
origin: gigabytedevelopers/FireFiles

List<AndroidAppProcess> runningAppProcesses = AndroidProcesses.getRunningAppProcesses();
for (AndroidAppProcess process : runningAppProcesses) {
  includeAppFromProcess(result, docId, process, null);
origin: jaredrummler/AndroidProcesses

  uid = status().getUid();
 AndroidProcesses.log("name=%s, pid=%d, uid=%d, foreground=%b, cpuacct=%s, cpu=%s",
   name, pid, uid, foreground, cpuacct.toString(), cpu.toString());
} else {
  uid = status().getUid();
 AndroidProcesses.log("name=%s, pid=%d, uid=%d foreground=%b, cpuacct=%s, cpu=%s",
   name, pid, uid, foreground, cpuacct.toString(), cpu.toString());
AndroidProcesses.log("name=%s, pid=%d, uid=%d foreground=%b", name, pid, uid, foreground);
com.jaredrummler.android.processesAndroidProcesses

Javadoc

Helper class to get a list of processes on Android.


Usage:

Get a list of running apps:

 
List<AndroidAppProcess> processes = AndroidProcesses.getRunningAppProcesses(); 

Get some information about a process:

 
AndroidAppProcess process = processes.get(location); 
String processName = process.name; 
Stat stat = process.stat(); 
int pid = stat.getPid(); 
int parentProcessId = stat.ppid(); 
long startTime = stat.stime(); 
int policy = stat.policy(); 
char state = stat.state(); 
Statm statm = process.statm(); 
long totalSizeOfProcess = statm.getSize(); 
long residentSetSize = statm.getResidentSetSize(); 
PackageInfo packageInfo = process.getPackageInfo(context, 0); 
String appName = packageInfo.applicationInfo.loadLabel(pm).toString(); 

Check if your app is in the foreground:

 
if (AndroidProcesses.isMyProcessInTheForeground()) { 
// do stuff 
} 

Get a list of application processes that are running on the device:

 
List<ActivityManager.RunningAppProcessInfo> processes = AndroidProcesses.getRunningAppProcessInfo(context); 

Limitations

System apps may not be visible because they have a higher SELinux context than third party apps.

Some information that was available through ActivityManager#getRunningAppProcesses() is not available using this library ( RunningAppProcessInfo#pkgList, RunningAppProcessInfo#lru, RunningAppProcessInfo#importance, etc.).

This is currently not working on the N developer preview.


Note: You should avoid running methods from this class on the UI thread.

Most used methods

  • getRunningAppProcesses
  • getRunningAppProcessInfo
    Returns a list of application processes that are running on the device.NOTE: On Lollipop (SDK 22) th
  • log
    Send a log message if logging is enabled.
  • setLoggingEnabled
    Toggle whether debug logging is enabled.

Popular in Java

  • Running tasks concurrently on multiple threads
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • Color (java.awt)
    The Color class is used encapsulate colors in the default sRGB color space or colors in arbitrary co
  • String (java.lang)
  • BigInteger (java.math)
    Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Option (scala)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now