Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>queryIntentActivities()</code> returns a static list of activities; this list is in your process, its contents don't change behind your back because the installed applications have changed since you retrieved the list.</p> <p>To handle the set of activities changing, you need to watch for PackageManager broadcasts about applications being installed/removed (or external storage being mounted/unmounted, etc) and update your list at that point.</p> <p>Here are the broadcasts to look for:</p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED" rel="nofollow noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED</a></p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_CHANGED" rel="nofollow noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_CHANGED</a></p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED" rel="nofollow noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REMOVED</a></p> <p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED" rel="nofollow noreferrer">http://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_REPLACED</a></p> <p>When an update to an application is installed, you will get a series of broadcasts, so production code should be a little smart about when it updates the list.</p> <p>Now that you know the list has possibly changed, you need to run your same code to re-requery the package manager, and put this new list in the adapter. Be sure to call <code>BaseAdapter.notifyDataSetChanged()</code> to tell the list view about the change when you do so.</p> <p>Here is the code in the Settings app that is used to implement the Manage Applications UI that shows the list of installed apps. This is admittedly complicated because it is doing a lot of things -- making sure all the work it does is off the main thread (to avoid UI glitching), perform queries for various app data in the background while the user is interacting with the UI, etc. It makes use of some private APIs in the system for computing app storage sizes that you wouldn't be able to use in a third party app, but the code of it is all just regular SDK code.</p> <p><a href="https://android.googlesource.com/platform/packages/apps/Settings/+/gingerbread-release/src/com/android/settings/applications/ApplicationsState.java" rel="nofollow noreferrer">https://android.googlesource.com/platform/packages/apps/Settings/+/gingerbread-release/src/com/android/settings/applications/ApplicationsState.java</a></p>
    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.
    1. VO
      singulars
      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