Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:12:34+00:00 2026-05-27T08:12:34+00:00

I have a custom listPreference I would like to display a list of apps

  • 0

I have a custom listPreference I would like to display a list of apps that can be launched (contain an activity with CATEGORY_LAUNCHER). The selection will be used later to launch the application. When I did a search for the solution, the list also contained apps that could not be launched. Is there any way to narrow this down?

public class AppSelectorPreference extends ListPreference {

@Override
public int findIndexOfValue(String value) {
    return 0;
    //return super.findIndexOfValue(value);
}

public AppSelectorPreference(Context context, AttributeSet attrs) {
    super(context,attrs);

    PackageManager pm = context.getPackageManager();
    List<PackageInfo> appListInfo = pm.getInstalledPackages(0); 
    CharSequence[] entries = new CharSequence[appListInfo.size()];
    CharSequence[] entryValues = new CharSequence[appListInfo.size()];

    try {
        int i = 0;
        for (PackageInfo p : appListInfo) {
            if (p.applicationInfo.uid > 10000) {
                entries[i] = p.applicationInfo.loadLabel(pm).toString();
                entryValues[i] = p.applicationInfo.packageName.toString();              

                i++;
            }         
        }
    } catch (Exception e) {

        e.printStackTrace();
    }   

    setEntries(entries);
    setEntryValues(entryValues);
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:12:34+00:00Added an answer on May 27, 2026 at 8:12 am

    Solved:

        final Context context = getBaseContext();
        final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        final List<ResolveInfo> pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0);
        CharSequence[] entries = new CharSequence[pkgAppsList.size()];
        CharSequence[] entryValues = new CharSequence[pkgAppsList.size()];
    
        int i = 0;
        for ( ResolveInfo P : pkgAppsList ) {
            entryValues[i] = (CharSequence) P.getClass().getName();
            entries[i] = P.loadLabel(context.getPackageManager());
            ++i;
        };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Custom List to display image with it's name like below... public class
I have custom validators and filters that I have created that I would like
I have custom component that I can place in my layout file (XML) for
I have custom page and id of list item. How can i show sharepoint
I have custom placeholders in a textarea and I would like every browser to
I have custom button, with an image that I'd like to shift down within
I have custom SPlist with some fields that I'd like to bind to a
I have custom List which has image field. I have to display the image
I have custom classes that I currently instantiate within App.xaml as resources. I want
I have custom event that has several different subscribers who will all use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.