Last active
December 10, 2015 21:18
-
-
Save bchazalet/4494656 to your computer and use it in GitHub Desktop.
List all installed application's uids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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