Wednesday, December 11, 2013

Code Snippet - Installed/Running Applications List

Create an Android Project as mentioned here.

List of Installed Apps:
Add the below code to get all the installed apps,

PackageManager packageManager = getPackageManager();
List<ApplicationInfo> appList =                  packageManager.getInstalledApplications(PackageManager.GET_ACTIVITIES);
for(ApplicationInfo info : appList){
    Log.i("AppInstallChecker",info.loadLabel(packageManager).toString());
 }

List of Running Apps:
Use the below code to get the list of running apps,

ActivityManager actvityManager = (ActivityManager) 
                                                                 this.getSystemService( ACTIVITY_SERVICE );
List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();
for(RunningAppProcessInfo info : procInfos){
        Log.i("Running",info.processName);
 }

Check for App installed or not :
protected boolean isAppInstalled(String packageName) {
        Intent mIntent = getPackageManager().getLaunchIntentForPackage(packageName);
        if (mIntent != null) {
            return true;
        }
        else {
            return false;
        }

    }


Courtesy : 
http://stackoverflow.com/questions/13566479/check-app-is-installed-on-device-android-code
http://www.dreamincode.net/forums/topic/138412-android-20-list-of-running-applications/

No comments:

Post a Comment