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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:47:08+00:00 2026-06-17T08:47:08+00:00

Okay, first off, i started (trying) to learn Java about 2 days ago. im

  • 0

Okay, first off, i started (trying) to learn Java about 2 days ago.
im trying to make an application that lists all installed applications (activityInfo.loadLabel)
and i want to launch the application on item click (activityInfo.packageName)
i have these stored in a list of AppItems

class AppItem{
    String _appname;
    public String getAppname(){return _appname;};
    public void setAppname(String value){_appname = value;};
    String _app;
    public String getApp(){ return _app; };
    public void setApp(String value){_app = value; };
}

I can add an array of strings to my listview just fine.
but how do i add 2 different values to the same row (so to speak) in a listview – in Java.
please tell me if you dont understand my question – and il’l try to elaborate best possible

here is my code:

ArrayList<AppItem> apps;
    @Override
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
        final List<ResolveInfo> pkgAppsList = getPackageManager().queryIntentActivities(mainIntent, 0);
        AppItem appItem = new AppItem();
        for (ResolveInfo applicationInfo : pkgAppsList) {
            appItem._appname = (String) applicationInfo.activityInfo.loadLabel(getPackageManager());
            appItem._app= applicationInfo.activityInfo.packageName;
            apps.add(appItem);
        }

        ArrayAdapter<AppItem> adapter = new ArrayAdapter<AppItem>(this,android.R.layout.simple_list_item_1,apps);

        ListView listView = new ListView(this);     
        listView.setAdapter(adapter);
         setContentView(listView);

         listView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position,
                    long id) {
                String item = ((TextView)view).getText().toString();            
                Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show();

            }
        });

    }
class AppItem{
    String _appname;
    public String getAppname(){return _appname;};
    public void setAppname(String value){_appname = value;};
    String _app;
    public String getApp(){ return _app; };
    public void setApp(String value){_app = value; };
}

or
is there an alternative to using

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
startActivity(LaunchIntent);

would i be able to start an application via its label name?

  • 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-06-17T08:47:08+00:00Added an answer on June 17, 2026 at 8:47 am

    Your ArrayAdapter displays the content of AppItem.toString() in the layout you give it.

    You can override toString() to display the label:

    public void toString() {
        return _appName;
    }
    

    in the onItemClick, you can get the item by calling

    AppItem item = (AppItem) parent.getItemAtPosition(position);
    

    or, given that appItem is accessible (either final or a field of your activity rather than a local variable to the method)

    apps.get(position);
    

    You can then have the package and call the activity :

    Intent intent = getPackageManager().getLaunchIntentForPackage(item.getAapp());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first, I can't stand Crystal! Okay, that's off my chest... Now, we have an
Okay, just learnt LINQ syntax about ten minutes ago, made a first program: public
Okay so I have two problems. First off I have made a square that
Okay, first off I am very, very new to java. For this project I
Okay, allow me to say first off that I am working on developing my
Okay so here is what I'm trying to accomplish. First of all below table
Okay, first off I will attempt to explain what I'm trying to do. I
First off, I'm using XCode 4.0.2. Okay, here is my issue. I can build
OKay first off this is really really similiar to the http://dribbble.com homepage. In the
Okay so first off, Im pretty new to programming, Ive only read a bit

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.