I eventually found two spectacular ways to get the list of
applications on the phone (including the gallery).  Both of these
methods are from Android source code!

Method one, if you want the list of applications in a list to iterate
through:
        PackageManager manager = context.getPackageManager();

        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);

        final List<ResolveInfo> apps = manager.queryIntentActivities
(mainIntent, 0);
        Collections.sort(apps, new ResolveInfo.DisplayNameComparator
(manager))

        if (apps != null) {
            final int count = apps.size();

            for (int i = 0; i < count; i++) {
                ResolveInfo info = apps.get(i);

                String packageName =
info.activityInfo.applicationInfo.packageName;
                String activityName = info.activityInfo.name;

                Drawable icon = info.activityInfo.loadIcon(manager);
          }
      }

Wow!

For the second method, in my case I needed the applications in a
pickable list.  I was able to poach some code from googles Launcher to
do this, and it also works fast and amazing.

                            Intent mainIntent = new Intent
(Intent.ACTION_MAIN, null);
                    mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                    Intent pickIntent = new Intent
(Intent.ACTION_PICK_ACTIVITY);
                    pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
                    startActivityForResult(pickIntent,
MoreIconsConstants.REQUEST_PICK_APPLICATION)

That will return in your onActivityResults method the intent for the
item that was picked!

Enjoy.


On Nov 27, 5:15 am, Mark Murphy <mmur...@commonsware.com> wrote:
> pcm2awrote:
> > Maybe I'm asking the totally wrong question here:
>
> > On any android phone I can press the up arrow and get a list of all
> > the built in and install application.  What is the recommended way to
> > get a list of all these items, their icons, and their start intents.
> > Current'y I'm using the PackageManager class.
>
> > If that is a no go, then on any android phone I can long press, select
> > shortcut, select application and a list comes up.  What is the
> > recommended way to get this list along with their icons and their
> > start intents?
>
> http://github.com/commonsguy/cw-advandroid/tree/master/Introspection/...
>
> The Gallery "application" shows up in the Launchalot list for the Google
> Ion and the Motorola DROID. HTC Sense devices (Hero, Tattoo) do not have
> a "Gallery", hence it will not show up.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Consulting/App Development:http://commonsware.com/consulting

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to