how to Get Running Applications List in Android Example Easy way

how to Get Running Applications List in Android Example Easy way

how to Get Running Applications List

Get Running Applications List in Android Example:- Here we will discuss about how to get running applications list in Android with an simple example. There are many applications and services which are running in your Android device. We can use ActivityManager.getRunningTasks(Integer.MAX_VALUE) API to get list of all running tasks in Android.


Lets extract running applications information for every running app. You can also get additional information using ActivityManager from same code snippet. So we will concentrate with below valuable application details.
1. Application Name
2. Application Activity Name
3. Application Package Name
4. Application Location

Get Running Applications List in Android Example Easy way
Get Running Applications List in Android Example Easy way

this is the articles of how to Get Running Applications List in Android Example Easy way

private void ListOfRunningTasks()
{
     ActivityManager activityManager = (ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);	  
     List<RunningTaskInfo> runningTaskInfo = activityManager.getRunningTasks(Integer.MAX_VALUE); 
     for(int ii = 0; ii < runningTaskInfo.size(); ii++) 
        {
           String taskName = runningTaskInfo.get(ii).baseActivity.toShortString();	  
	   int lastIndex = taskName.indexOf("/");
	   if(-1 != lastIndex)
	    {
		taskName = taskName.substring(1,lastIndex);
	    }
	   PackageManager packageManager = getPackageManager();
	   try 
	   {
		applicationInfo = packageManager.getApplicationInfo(taskName, 0);
	   }
	   catch (final NameNotFoundException e) {}
           final String title = (String)((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo) : "???");
      }
}

Note:

ActivityManager  activityManager =(ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE);

The above code snippet will get the running instance of Android Activity Service. Then We can retrieve the list of all running applications and it’s other details from the activityManager variable like below.

List<RunningTaskInfo>  runningTaskInfo =activityManager.getRunningTasks(Integer.MAX_VALUE);


Note: From the above code snippet, you can use ‘activityManager’ variable and its member functions to get other details.

this is the article of how to Get Running Applications List in Android Example Easy way


I hope the above code snippet about Get Running Applications List in Android will help at it’s best.

Get Installed Applications List in Android Example


Here you will find the simplest way to get installed applications list in Android Phones. We can retrieve all installed applications list using PackageManager and ResolveInfo in Android.

ResolveInfo and PackageManager are Android components which provides us all installed applications details as per our requirement.


In this tutorial, You will find below details for each of your installed application in your Android devices.
1. Get Application name.
2. Get Application Package Name.
3. Get Application Icon etc.


Code Snippet for getting installed applications in Android.

void GetInstalledAppList()
{
  final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
  mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
  final List pkgAppsList = getPackageManager().queryIntentActivities( mainIntent, 0);
  for (Object object : pkgAppsList) 
  {
    ResolveInfo info = (ResolveInfo) object;
    Drawable icon    = getBaseContext().getPackageManager().getApplicationIcon(info.activityInfo.applicationInfo);
    String strAppName  	= info.activityInfo.applicationInfo.publicSourceDir.toString();
    String strPackageName  = info.activityInfo.applicationInfo.packageName.toString();
    final String title 	= (String)((info != null) ? getBaseContext().getPackageManager().getApplicationLabel(info.activityInfo.applicationInfo) : "???");
   }
 }


From the above code snippet, you can find all required information. You can now show all information using a List or Vector class and then show on a ListView in Android.


I hope this small code snippet about Get Installed Applications List in Android will help you at it’s best. Happy cording.

this is the article of how to Get Running Applications List in Android Example Easy way

this website is for learning purpouse we will provide you new technology related article that wiill help you to improve your knowledge..

you can follow me on my facebook page and instagram gram page..

please comment me for any suggestion so that i improov my skill please contect me in my contact page or comment me on my website name – allntech

i am very happy to see your comment we are provideing new technologys and gadget that will really helpful to you and your family

FOLLOW US ON FACEBOOK INSTAGRAM TWITTER

Steps to Download Android Apps from Google Play Store

Fully Automatic Washing Machine makes washing easy

Communication Between Service and Activity in Android Example

Mozilla Firefox OS – New Competitor in Smartphone Market

Insert New Contact in Android Code Example

The Best Ways to Transfer Photos from Your iPhone to Your Laptop

Top five payment gateway list that you must know cheap

Leave a Comment