Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the application icons for currently running tasks in android
    primarykey
    data
    text
    <p>I successfully got the application icons of the currently installed applications with the following snippet:</p> <pre><code>List&lt;ApplicationInfo&gt; list = pm.getInstalledApplications(PackageManager.GET_ACTIVITIES); for (int i=0; i&lt; list.size(); i++) { randInt1 = new Random().nextInt(list.size()); ApplicationInfo appInfo = list.get(randInt1); packageName = appInfo.packageName; appLabel = (String) pm.getApplicationLabel(appInfo); icon = pm.getApplicationIcon(appInfo); System.out.println("Icon ==&gt; " +icon); } </code></pre> <hr> <p>How do I return the icons of the currently running tasks and not just the installed applications?</p> <hr> <p>Ok, this is what I ended up doing and it appears to be working, but is there a way to retrieve only the tasks that were launched by the user like a task killer would return and not dormant system processes? Can they be filtered by category maybe? The goal is to return a random application icon for one of the currently running tasks that were recently launched by the user, if that helps.</p> <pre><code>int ii=0; List&lt; ActivityManager.RunningTaskInfo&gt; Runningtasks= mgr.getRunningTasks(30); for(ii=0;ii&lt;Runningtasks.size();ii++) { randInt1 = new Random().nextInt(Runningtasks.size()); ComponentName comName=Runningtasks.get(randInt1).topActivity; packageName = comName.getPackageName(); //String Classname = comName.getClassName(); System.out.println("icon====&gt; "+icon); System.out.println("packageName====&gt; "+packageName); // Toast toast1 = Toast.makeText(pm, packageName, LONG); // toast1.show(); } try{ icon = pm.getApplicationIcon(packageName); }catch(Exception e){} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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