I have made a small method to display the installed application name in android. But when i give \"name\" attribute its showing exception error. And when i give \"packageNam
by using this you can get installed app package names and app names
List<PackageInfo> packageInfos=getPackageManager().getInstalledPackages(0);
for (PackageInfo packageInfo:packageInfos)
{
Log.d(TAG,"packageName "+packageInfo.packageName);
Log.d(TAG,"appname "+getPackageManager().getApplicationLabel(packageInfo.applicationInfo));
}
My guess is your code is throwing a NullPointerException because the name
field is null. In any event, what you probably want is:
String appname = packageManager.getApplicationLabel(pk).toString()