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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:23:52+00:00 2026-06-16T13:23:52+00:00

I’m trying to figure out how i can implement this code into my existing

  • 0

I’m trying to figure out how i can implement this code into my existing source code. Currently i have some source that displays a list-view of all the installed apps and on-click will send intent to the application. I’m needing some support on how to pull the icon and add this into the list view.

Any help, source code editing, links, etc would help me resolve this.

Thank you

ListInstalledActivitiesActivity

public class ListInstalledActivitiesActivity extends ListActivity {

    // Buffer used to store package and class information, and also determine the number of installed activities
    private ArrayList<String[]> _activitiesBuffer = null;

    // Buffers for package and class information
    private String[] _packages = null;
    private String[] _classes = null;

    // Index used to fill buffers
    private int _index = 0;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main3);
        // Get all installed activities (package and class information for every activity)
        getAllInstalledActivities();              

        // Set content to GUI
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, _classes));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        // Add listener
        lv.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                // When clicked, show a toast with the selected activity
                Toast.makeText(
                    getApplicationContext(), 
                    ((TextView) view).getText(), 
                    Toast.LENGTH_SHORT).show();

                // When clicked, start selected activity, if allowed or possible
                try {

                    Intent intent = new Intent().setClassName(
                            _packages[position], // package 
                            _classes[position]); // class
                    startActivity(intent);

                } catch (Exception e) {
                    Toast.makeText(getApplicationContext(), "Unable to start selected application.", Toast.LENGTH_SHORT);
                }

          } // public void onItemClick(AdapterView<?> parent, View view, int position, long id)

        });

    } // public void onCreate(Bundle savedInstanceState)

    /*
     * Get all installed activities
     */
    private void getAllInstalledActivities() {


        // Initialize activities buffer
        _activitiesBuffer = new ArrayList<String[]>();

        final Intent intent = new Intent(Intent.ACTION_MAIN, null);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        final List<ResolveInfo> pkgAppsList = getPackageManager().queryIntentActivities( intent, 0);

        Iterator<ResolveInfo> iterator1 = pkgAppsList.iterator();
        while (iterator1.hasNext()) {

            ResolveInfo resolveInfo = iterator1.next();

            String[] buf = new String[] {
                    resolveInfo.activityInfo.packageName, 
                    resolveInfo.activityInfo.name};

            _activitiesBuffer.add(buf);

        } // while (iterator1.hasNext())

        _packages = new String[_activitiesBuffer.size()];
        _classes = new String[_activitiesBuffer.size()];

        Iterator<String[]> iterator2 = _activitiesBuffer.iterator();
        while (iterator2.hasNext()) {

            String[] buf = iterator2.next();

            // Store package information
            _packages[_index] = buf[0]; 

            // Store class information
            _classes[_index] = buf[1];

            _index++;

        } // while (iterator2.hasNext())

    } // private void getAllInstalledActivities()

      }

main3.xml

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical" >

     <ListView
         android:id="@+id/android:list"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent" />

      <!-- <ImageView -->
      <!--android:id="@+id/ImageView02" -->
      <!--android:layout_width="fill_parent" -->
      <!--android:layout_height="wrap_content" -->
      <!--android:layout_marginBottom="10dp" -->
      <!--android:paddingBottom="5dp" -->


      </LinearLayout>
  • 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-16T13:23:54+00:00Added an answer on June 16, 2026 at 1:23 pm

    To fetch the names and icons of the installed applications, you need to use Package Manager class, here is a snippet of code, that will let you fetch application’s name and icons

       import android.app.Activity;
    import android.content.Intent;
    import android.content.pm.PackageManager;
    import android.content.pm.ResolveInfo;
    import android.graphics.drawable.Drawable;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.ImageView;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    
    public class FetchApplicationsActivity extends Activity {
    
        TextView data;
        ImageView image1;
        LinearLayout holdlayout;
        View l1;
        private ArrayList results;
        List<ResolveInfo> list;
        TextView result;
        String str = "";
        Drawable icon;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            l1 = findViewById(R.id.Layout1);
            results = new ArrayList();
            PackageManager pm = this.getPackageManager();
            Intent intent = new Intent(Intent.ACTION_MAIN, null);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);
            list = pm.queryIntentActivities(intent,
                    PackageManager.PERMISSION_GRANTED);
            for (ResolveInfo rInfo : list) {
                str = rInfo.activityInfo.applicationInfo.loadLabel(pm).toString()
                        + "\n";
                results.add(rInfo.activityInfo.applicationInfo.loadLabel(pm)
                        .toString());
                Log.w("Installed Applications", rInfo.activityInfo.applicationInfo
                        .loadLabel(pm).toString());
                icon = rInfo.activityInfo.applicationInfo.loadIcon(pm);
                holdlayout = new LinearLayout(getApplicationContext());
                holdlayout.setOrientation(LinearLayout.HORIZONTAL);
                data = new TextView(getApplicationContext());
                data.setText(str);
                image1 = new ImageView(getApplicationContext());
                image1.setBackgroundDrawable(icon);
                ((ViewGroup) holdlayout).addView(image1);
                ((ViewGroup) holdlayout).addView(data);
                ((ViewGroup) l1).addView(holdlayout);
    
            }
        }
    }
    

    Edit- You can define your main.xml as,

    ?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
    
    
        <ScrollView
            android:id="@+id/scrollView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    
    
            <LinearLayout
            android:id="@+id/Layout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
    
    
    
        </LinearLayout>
        </ScrollView>
    
    </LinearLayout>
    

    Here I have created dynamic textviews, Imageviews and layouts to show the names and icons. You can create your own customized list to show this.

    Edit2- Here is a good link on how to create customized list and also look here. I think these will solve the issue.

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

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.