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
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
List of 15 Best iOS App Development Tools
5 Best Resources to Get Started with Android Nougat
Learn How to Position the Toast Message
Activity And Fragments – How They Communicate
Scroll To A Selected Position In Listview
How To Use Custom Fonts In Android
How To Fix Flickering In SpriteGame
Custom ListView In A Dialog In Android