Wednesday, June 22, 2011

Installed application information in Android

Using PackageManager we can get the all installed application details in Android device like package name,version code,version info,class name etc.

Code snippet:

PackageManager pckMgr;
pckMgr = getPackageManager();
List appInfo = pckMgr.getInstalledPackages(PackageManager.GET_ACTIVITIES);
Log.i("Number of Applications are installed " ,":"+ appInfo.size());
for ( int cnt=0; cnt < appInfo.size(); cnt++){

Log.i("Package name ",":"+appInfo.get(cnt).packageName);
Log.i("Application name ",":"+appInfo.get(cnt).applicationInfo.loadLabel(getPackageManager()));
Log.i("Version code ",":"+appInfo.get(cnt).versionCode);
Log.i("Version name ",":"+appInfo.get(cnt).versionName);

}