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

  • Home
  • SEARCH
  • 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 6227485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:14:19+00:00 2026-05-24T09:14:19+00:00

I am developing a small application which displays the installed application as a list

  • 0

I am developing a small application which displays the installed application as a list in a spinner. Only the application name is displayed as spinner values. Whenever I select an application from spinner I need to retrieve the UID of the selected application. How can I implement the function?

The following is my code for getting the application name from the spinner

appspinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View arg1,
                int app_pos, long app_id) {
            // TODO Auto-generated method stub
            String app_selected=parent.getItemAtPosition(app_pos).toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
            return;
        }
    });

The installed application is stored in a list using the PackageManager class and using PackageInfo class I am getting the name of the application.

  • 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-24T09:14:19+00:00Added an answer on May 24, 2026 at 9:14 am

    You will need to use PackageManager to get the package information about whatever app you select in the list. I haven’t done this with a Spinner but i’m sure it should work the same as it did in my ListView.

    appspinner.setOnItemSelectedListener(new OnItemSelectedListener() {
    
            @Override
            public void onItemSelected(AdapterView<?> parent, View arg1,
                    int app_pos, long app_id) {
            // TODO Auto-generated method stub
            String app_selected=parent.getItemAtPosition(app_pos).toString();
    
            final PackageManager pm = getPackageManager();
            //get a list of installed apps.
            List<ApplicationInfo> packages = pm.getInstalledApplications(
                    PackageManager.GET_META_DATA);
            int UID;
            //loop through the list of installed packages and see if the selected
            //app is in the list
            for (ApplicationInfo packageInfo : packages) {
                if(packageInfo.packageName.equals(app_selected)){
                    //get the UID for the selected app
                    UID = packageInfo.uid;
                    break; //found a match, don't need to search anymore
                }
    
            }
    
            //Do whatever with the UID
            Log.i("Check UID", "UID is: " + UID);               
    
        }
    
        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
            return;
        }
    });
    

    You might want to see how packageName returns the packageName so you can try to match it with whatever was selected.

    hope this points you in the right direction and helps you out. Good Luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a small application which lists the contents from files of a
I am developing a small application which lists only those application which connects to
I am developing a small business application which uses Sqlserver 2005 database. Platform: .Net
I am developing a small intranet based web application. I have YSlow installed and
I am developing a small application in which I want to create 20 radio
I'm developing a small application that reads data from a database and displys it
I am developing a small application in android in which i have few image
I'm developing a small utility application that needs to detect whether another one has
In the small application that I'm currently developing for a customer I need to
I'm developing a small tray-icon application for Windows and I need to display non-intrusive

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.