Skip to content Skip to sidebar Skip to footer

How Can Get How Many Apps Installed In My Device And There Names Or Last Accessed Information?

I need to show the last accessed app information in my app. How can i get this information?

Solution 1:

You can use this code to get the list of applications:

PackageManagerpm=this.getPackageManager();
Intentintent=newIntent(Intent.ACTION_MAIN, null);

StringactivityName= rInfo.activityInfo.name;
List<ResolveInfo> list = pm.queryIntentActivities(intent, PackageManager.PERMISSION_GRANTED);

for (ResolveInfo rInfo : list) {
    pkg = rInfo.activityInfo.applicationInfo.packageName;
    if (pm.getLaunchIntentForPackage(pkg) == null) {
      continue;
    }
    Stringlabel= rInfo.activityInfo.applicationInfo.loadLabel(pm).toString();
    arrayList.add(newAppEntry(label, activityName, pkg, null));
}

Solution 2:

// How to detect which is the current top activity.

public boolean whatIsCurrentActivity()  
{  
 ActivityManager am = (ActivityManager) mContext.getSystemService(mContext.ACTIVITY_SERVICE);  
 List ActivityManager.RunningTaskInfo taskInfo = am.getRunningTasks(1);  
               if(taskInfo != null ){  
                        System.out.println("Top activity - Package name of the process is "+taskInfo.get(0).topActivity.getPackageName() );  
       }  

Post a Comment for "How Can Get How Many Apps Installed In My Device And There Names Or Last Accessed Information?"