How To Get Installed Activity List

This example shows how we can list all activities that can be performed for the given intent.
Algorithm:

1.) Create a new project by File-> New -> Android Project name it InstalledActivityList.

2.) Run for output.

Steps:

1.) Create a project named InstalledActivityList and set the information as stated in the image.

Build Target: Android 4.4
Application Name: InstalledActivityList
Package Name: com.example.InstalledActivityList
Activity Name: InstalledActivityListActivity

installedactivitylist1

2.) Open InstalledActivityListActivity.java file and write following code there:

 

package com.example.installedactivitylist;

import java.util.List;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import android.app.ListActivity;
import android.content.Intent;
import android.content.pm.ResolveInfo;

public class InstalledActivityListActivity extends ListActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);

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

setListAdapter(new ArrayAdapter<ResolveInfo>(
this,
android.R.layout.simple_list_item_1,
intentList));

Toast.makeText(getApplicationContext(),
"no of activities: " + intentList.size(),
Toast.LENGTH_LONG).show();
}
}

 

 

3.) Compile and build the project.

Output

installedactivitylist2