2

我想分别列出已安装和系统应用程序。下面是我的代码

List<ApplicationInfo> appList = packageManager.getInstalledApplications(0);
if(appList != null && !appList.isEmpty()){
        for (ApplicationInfo appInfo : appList) {
        Intent intent = packageManager.getLaunchIntentForPackage(appInfo.packageName);
        if(intent != null){
            ComponentName componentName = intent.getComponent();
            if((appInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
                //It is a system app
            }else{
                //It is an installed app.
            }
        }
    }
}

我想在单击 listview 时启动每个应用程序。但是对于某些应用程序,如联系人、地图等, componentName .getClassName()显示为“ com.android.internal.app.ResolverActivity ”......我怎样才能获得确切的类名这种类型的应用程序。我无法使用ResolveInfo,因为它很难对应用程序进行分类。

如何使用包名获取应用程序的确切类名?

提前致谢

4

1 回答 1

-1

您可以询问 packageManager:

CharSequence label = "";
for (ApplicationInfo appInfo : appList)    
    label = packageManager.getApplicationLabel(appInfo);
于 2013-03-25T12:15:03.323 回答