Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This helper function retrieves all installed apps with the application name, package name, version-number and -code as well as the icons. The method <code>getPackages()</code> returns an <code>ArrayList</code> with all the apps.</p> <blockquote> <pre><code>class PInfo { private String appname = ""; private String pname = ""; private String versionName = ""; private int versionCode = 0; private Drawable icon; private void prettyPrint() { Log.v(appname + "\t" + pname + "\t" + versionName + "\t" + versionCode); } } private ArrayList&lt;PInfo&gt; getPackages() { ArrayList&lt;PInfo&gt; apps = getInstalledApps(false); /* false = no system packages */ final int max = apps.size(); for (int i=0; i&lt;max; i++) { apps.get(i).prettyPrint(); } return apps; } private ArrayList&lt;PInfo&gt; getInstalledApps(boolean getSysPackages) { ArrayList&lt;PInfo&gt; res = new ArrayList&lt;PInfo&gt;(); List&lt;PackageInfo&gt; packs = getPackageManager().getInstalledPackages(0); for(int i=0;i&lt;packs.size();i++) { PackageInfo p = packs.get(i); if ((!getSysPackages) &amp;&amp; (p.versionName == null)) { continue ; } PInfo newInfo = new PInfo(); newInfo.appname = p.applicationInfo.loadLabel(getPackageManager()).toString(); newInfo.pname = p.packageName; newInfo.versionName = p.versionName; newInfo.versionCode = p.versionCode; newInfo.icon = p.applicationInfo.loadIcon(getPackageManager()); res.add(newInfo); } return res; } </code></pre> </blockquote> <p>I hope it will help you.</p> <p>Thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload