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 5845845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:29:35+00:00 2026-05-22T12:29:35+00:00

UPDATE: Now looking for Package Name as opposed to PID I have an app

  • 0

UPDATE: Now looking for Package Name as opposed to PID

I have an app that diplays a listview of all the installed apps on the device. I want to create an OnItemClickListener that passes the Package Name of the app selected to a method.

Here is my code:

public class Main extends ListActivity {

    private static final int ACTIVITY_CREATE=0;
    public static final int Menu1 = Menu.FIRST;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);

        final PackageManager pm = this.getPackageManager();

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

        final ArrayList<ResolveInfo> list =
                (ArrayList<ResolveInfo>) pm.queryIntentActivities(intent, 
                        PackageManager.PERMISSION_GRANTED);
        for (ResolveInfo rInfo : list)
        {
            Log.i("Installed Applications " + rInfo.activityInfo.
                    applicationInfo.loadLabel(pm).toString(), null);
        }

        final ArrayAdapter<ResolveInfo> adapter = 
            new ArrayAdapter<ResolveInfo>(this, R.layout.list_item, list)
            {
            @Override
            public View getView(int position, View convertView, ViewGroup parent)
            {
                if (convertView == null)
                    convertView = LayoutInflater.from(parent.getContext()).
                        inflate(R.layout.list_item, parent, false);

                final String text = list.get(position).activityInfo.
                    applicationInfo.loadLabel(pm).toString();
                ((TextView)convertView.findViewById(R.id.text)).setText(text);

                final Drawable drawable = list.get(position).activityInfo.applicationInfo.loadIcon(pm);
                ((ImageView)convertView.findViewById(R.id.image)).setImageDrawable(drawable);

                return convertView;
            }

            };
        setListAdapter(adapter);

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);
        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {

                // On Item Click Activity

                // This is where I would like to pass the package name to a method
            }
          });
    }

Any help would be greatly appreciated!

  • 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-22T12:29:36+00:00Added an answer on May 22, 2026 at 12:29 pm

    You can retrieve the package name for the activityInfo member of the ResolveInfo instance whose item you just clicked on:

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
    {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id)
        {
            final String packageName = list.get(position).activityInfo.packageName;
            Log.i("PACKAGE", packageName);
            //TODO: Pass this packageName to a method
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
I installed WSS Infrastructure Update and MOSS Infrastructure Update ( http://technet.microsoft.com/en-us/office/sharepointserver/bb735839.aspx ) and now
So I have been using Leopard for a year now, and the lastest update
Update: I have now written a PHP extension called php_ssdeep for the ssdeep C
Update 3: the restrict access, using the security tab works now. (that's manually) now
I have an app in the App Store that I produced using the Adobe
I got this far: :~ curl -u username:password -d status=new_status http://twitter.com/statuses/update.xml Now, how can
Update Thanks to Marc's help the AlphaPagedList class is now available on CodePlex if
UPDATE 2011.09.13 This bug has been resolved by Adobe. The example code below now
When you run something similar to: UPDATE table SET datetime = NOW(); on a

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.