Skip to content

Instantly share code, notes, and snippets.

@bchazalet
Last active December 10, 2015 21:18
Show Gist options
  • Save bchazalet/4494656 to your computer and use it in GitHub Desktop.
Save bchazalet/4494656 to your computer and use it in GitHub Desktop.
List all installed application's uids
package com.commonsware.android.tuning.traffic;
import java.util.HashMap;
import android.content.Context;
import android.content.pm.ApplicationInfo;
class TrafficSnapshot {
TrafficRecord device=null;
HashMap<Integer, TrafficRecord> apps = new HashMap<Integer, TrafficRecord>();
TrafficSnapshot(Context ctxt) {
device=new TrafficRecord();
HashMap<Integer, String> appNames=new HashMap<Integer, String>();
for (ApplicationInfo app : ctxt.getPackageManager().getInstalledApplications(0)) {
appNames.put(app.uid, app.packageName);
}
for (Integer uid : appNames.keySet()) {
apps.put(uid, new TrafficRecord(uid, appNames.get(uid)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment